-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
CSS Variables Being Overridden After Page Load #43482
Comments
Thanks for asking. The root cause might be the insertion point. I managed to find a workaround by wrapping the CSS theme variables with 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 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 |
This is a known issue for Emotion emotion-js/emotion#2790. It should be fixed from the Emotion side. |
I mark this as a bug from Material UI user perspective. The |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note We value your feedback @jamesga1! How was your experience with our support team? |
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:
The text was updated successfully, but these errors were encountered: