Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Access alert background colors in sx function. #45499

Open
circularchaos opened this issue Mar 6, 2025 · 5 comments
Open

[docs] Access alert background colors in sx function. #45499

circularchaos opened this issue Mar 6, 2025 · 5 comments
Labels
docs Improvements or additions to the documentation support: docs-feedback Feedback from documentation page

Comments

@circularchaos
Copy link

circularchaos commented Mar 6, 2025

Related page

https://mui.com/material-ui/react-alert/

Kind of issue

Missing information

Issue description

The MUI alert component uses a very light background for all severities. These light colors are not accessible when using the sx property for custom components e.g. background: (theme) => theme.palette. and are also not defined in the Palette docs: https://mui.com/material-ui/customization/palette/.

Context

No response

Search keywords: alert colors background

@circularchaos circularchaos added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: docs-feedback Feedback from documentation page labels Mar 6, 2025
@siriwatknp
Copy link
Member

It can be accessed when CSS theme variables feature is enabled.

const theme = createTheme({ cssVariables: true });

<ThemeProvider theme={theme}>
  <Box sx={{ bgcolor: 'Alert.successStandardBg', width: 200, height: 200 }} />
</ThemeProvider>

To learn more:

@siriwatknp siriwatknp removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 6, 2025
Copy link

github-actions bot commented Mar 6, 2025

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@circularchaos How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@siriwatknp siriwatknp reopened this Mar 6, 2025
@siriwatknp
Copy link
Member

siriwatknp commented Mar 6, 2025

Reopen, I think the available tokens have to be documented.

@siriwatknp siriwatknp added the docs Improvements or additions to the documentation label Mar 6, 2025
@circularchaos
Copy link
Author

circularchaos commented Mar 6, 2025

Thanks @siriwatknp, doesn't it also belong in the palette theme function object too? e.g.

<Box sx={{ bgcolor: (theme) => theme.palette.success.lightest, width: 200, height: 200 }} />.

@siriwatknp
Copy link
Member

Thanks @siriwatknp, doesn't it also belong in the palette theme function object too? e.g.

<Box sx={{ bgcolor: (theme) => theme.palette.success.lightest, width: 200, height: 200 }} />.

No it does not. The background of the alert is calculated using lighten or darken, you can see here.

When css variables feature is enabled, the calculated value is attached to theme.vars.palette.Alert.successStandardBg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation support: docs-feedback Feedback from documentation page
Projects
None yet
Development

No branches or pull requests

2 participants