-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Dark mode flicker on Vite.js #44250
Comments
The vite setup you provided is client side only. It won't be possible to prevent flickering because Material UI needs to render before generating the CSS variables. On the other hand, the Next.js works because of SSR setup + Note: |
The possible way is to use Pigment CSS to extract CSS variables at build time. |
@siriwatknp Thanks for clarifying. Pigment CSS is currently only a experimental version. Is this a good time to migrate to Pigment CSS? Because my application has quite a few components. I tried integrating before but had a lot of errors. Maybe I will try again. Currently I only see examples for Vite.js and Next.js Can you please tell me where I can get an example of Pigment CSS + CRA (react-script)? |
I don't think we will add an example for CRA, it's outdated. Is there any reason that you cannot use Vite? |
Personally, I still like to use Vite.js because of its performance. However, some of my customers still want to use CRA in their projects. So that's why I mentioned this |
Hey, with the latest release. You can provide <ThemeProvider theme={theme} noSsr> See https://mui.com/material-ui/customization/dark-mode/#disable-double-rendering |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @mtr1990 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. |
Steps to reproduce
Dark mode flicker Vite.js version :
https://stackblitz.com/edit/github-5gkalw?file=src%2Fmain.tsx,src%2Ftheme.tsx,src%2FApp.tsx,node_modules%2F%40mui%2Fmaterial%2FCssBaseline%2FCssBaseline.d.ts
For comparison I recreated the Next.js version
https://stackblitz.com/edit/github-rfxsj1?file=src%2Fapp%2Fpage.tsx,src%2Fapp%2Flayout.tsx,src%2Ftheme.ts,src%2Fcomponents%2FApp.tsx
Result
flicker.mp4
Current behavior
Dark mode flicker on Vite.js version with MUI v6.
in MUI v5 when used with
CssVarsProvider
andextendTheme
don't have this problem.Expected behavior
No flicker when refresh page
Context
No response
Your environment
No response
Search keywords: Dark mode flicker
The text was updated successfully, but these errors were encountered: