-
-
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] Nested theme #34278
Comments
@mtr1990 First of all, thank you so much for opening the issue. I have been waiting for the nesting CSS variables theme. Before we jump to a conclusion, can you first share why you need a nested CSS variables theme? |
Hi @siriwatknp , Thanks for your feedback on this issue Actually the functions change color, or switch light/dark mode… I can work directly on a single theme without nesting. But in terms of component management, it won't be optimized Currently the structure I'm using with ThemeProvider looks like this: <ThemeProvider>
<DarkModeProvider>
<ChangePrimaryColorProvider>{children}</ChangePrimaryColorProvider>
</DarkModeProvider>
</ThemeProvider> https://codesandbox.io/s/awesome-ellis-rt1ol9?file=/theme/palette.ts You can remove functions like : or When not in use without affecting the main structure of the theme. I also want to apply this similar structure when using with |
I have the same needs for the nested cssVarsProvider, and wondering if there will be an update with the feature. |
Can you share a codesandbox that I can take a look? |
I ran into the same issue. Here's a codesandbox using the docs example for nested themes. On the root / page it's using nested with cssVariables: true and the error pictured above occurs. |
Wanted to bump this. Having the same issue. My app uses the new css variables in v6 but we have needs for certain parts of the app to force light mode or force dark mode. One of our use cases is a modal containing an iframe to a page that does not support dark mode, so we need to force the surrounding modal into light mode to keep a consistent experience. We also have a different part of the app that we want to always have the inverse color scheme of the system one (i.e. in dark mode this part of the app would be light mode and vice versa). |
Duplicates
Latest version
Current behavior 😯
Before when using nested themes with ThemeProvider and it worked fine.
I recently switched to CSS variables to better support next.js in Darkmode.
Above code works fine with following version dependencies:
But after i upgrade the dependencies get the following errors
Expected behavior 🤔
No error when setting up
Steps to reproduce 🕹
Steps:
Context 🔦
Nested theme:
based on CSS variables:
https://mui.com/material-ui/experimental-api/css-variables/#main-content
use
CssVarsProvider
instead ofThemeProvider
Sanbox : https://codesandbox.io/s/keen-lewin-bkchg9?file=/demo.tsx
Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: