sx prop does not correctly apply theme in nested ThemeProviders with ColorMode
See original GitHub issueDescribe the bug
When having an application that has a nested ThemeProviders with the same theme and color modes but different values, toggling the colorMode changes the colorMode and theme in both the top level and nested theme provider, but when utilizing that theme in the nested component with the sx prop, the wrong colour gets applied.
To Reproduce Here is a simple codesandbox that reproduces the issue. https://codesandbox.io/s/exciting-banzai-hrjom?file=/src/index.js Expected behavior
In the example provided, I would expect the inner components background value for light mode to be “darkcyan”, and it is if you print out the theme object. But when its applied to the div using sx={{ bg: "background" }}
it applies “red”.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Developers - sx prop does not correctly apply theme in nested ...
Describe the bug. When having an application that has a nested ThemeProviders with the same theme and color modes but different values, ...
Read more >MUI component received wrong theme color through SX ...
Either you have incorrectly nested themes, or you have imported a component that ships its own Mui palette... such as components from material- ......
Read more >Nested Theme Providers - Theme UI
The inner Theme Provider will not create a new color mode state, but inherit this from the parent. Functional Themes. The nested ThemeProvider...
Read more >Theming with React and MUI - Welcome, Developer
Learn how to create custom themes to React app using MUI. ... The goal of this post is not to dive into the...
Read more >Upgrading to v1 - Chakra UI
Theme -aware sx prop: Just like theme-ui , we've added support for the sx prop to ... You can skip this if you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We could split CollorModeProvider into actual React context provider and consumer? Provide color mode in top level ThemeProvider (from theme-provider package, not core), consume in all ThemeProviders.
Hi @hasparus , I didn’t get an opportunity to look at this yet. Is there any chance one of the existing maintainers of theme-ui will be able to tackle it?