Closed jamesga1 closed 3 days ago
Thanks for asking. The root cause might be the insertion point. ~Try this https://mui.com/material-ui/migration/v5-style-changes/#style-library~
I managed to find a workaround by wrapping the CSS theme variables with@layer
:
const sheets = theme.generateStyleSheets();
const newSheets = sheets.map((sheet) => {
return {
"@layer tokens": sheet,
};
});
theme.generateStyleSheets = () => newSheets;
function App() {
return <ThemeProvider theme={theme}>…</ThemeProvider>
}
When using NX we have noticed that the emotion global style are inserted last and thus override anything in styles.css even if I add <StyledEngineProvider injectFirst >
above the theme provider.
If I make the change the hot reload moves the styles related css to the bottom
Not sure if this is the intention but will try the work around
When using NX we have noticed that the emotion global style are inserted last and thus override anything in styles.css even if I add
<StyledEngineProvider injectFirst >
above the theme provider.
This is a known issue for Emotion https://github.com/emotion-js/emotion/issues/2790. It should be fixed from the Emotion side.
I mark this as a bug from Material UI user perspective. The <StyledEngineProvider injectFirst>
should work but it's not. I have a PR to fix this issue.
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] We value your feedback @jamesga1! How was your experience with our support team? If you could spare a moment, we'd love to hear your thoughts in this brief Support Satisfaction survey. Your insights help us improve!
Sorry if there's a better location to ask this and feel free to move it wherever.
We've recently updated from v5.16.7 up to 6.0.0 and would like to use css-variables, but ideally without having to populate createThemes with a light and dark mode palette.
theme.tsx
styles.scss
If we update the styles.scss with a new value and HMR updates the page, we are able to see the correct color, but as soon as we refresh the page, the colors will default back to their stock values:
Is there a way to be able to accomplish this, or will the mui generated css variables always override those in styles.scss.
Search keywords: