-
-
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
CssVarsProvider is deprecated but seems to be required to use useColorScheme() when creating a theme with createTheme() #43628
Comments
Here is a working example: https://stackblitz.com/edit/vitejs-vite-kghdr6?file=src%2FMuiProvider.tsx,src%2Fthemes%2Findex.tsx I've updated it using the docs: |
Thanks. You might be on the right track, but your example doesn't work. Check my example again and don't remove |
@craig-bowers Thanks for reporting the issue, since v6, You only need a Remove 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 @craig-bowers! How was your experience with our support team? |
Thank you so much. Not sure if I missed that in the documentation, but this certainly did the trick and it's working again! |
Steps to reproduce
Link to live example: https://stackblitz.com/edit/vitejs-vite-jpbmfh?file=src%2FMuiProvider.tsx
Steps:
<CssVarsProvider>
wrapping my<ThemeProviders>
everything looks and behaves like it should. Click the "Toggle color scheme" button several times and watch how the scroll bar will change color.<CssVarsProvider>
and I no longer have access tomode
fromuseColorScheme()
in my ./themes/index.tsx file. Try clicking the "Toggle color scheme" button several times again and you'll see that the scroll bar colors do not change.Current behavior
<ThemeProvider>
does not have access tomode
fromuseColorScheme()
unless it is wrapped with<CssVarsProvider>
Expected behavior
<CssVarsProvider>
has been deprecated, so we need a way to dynamically style components such as theMuiCssBaseline
based on the current mode.Context
I want to customize my application theme and components using a custom
<ThemeProvider>
Your environment
npx @mui/envinfo
Search keywords: CssVarsProvider, createTheme, useColorScheme, mode, dark mode, ThemeProvider
The text was updated successfully, but these errors were encountered: