Semantic tokens don't work with DarkMode and LightMode component
See original GitHub issueDescription
Semantic tokens don’t work with DarkMode component.
Link to Reproduction
https://codesandbox.io/s/intelligent-thompson-563p3?file=/src/index.tsx
Steps to reproduce
This code is not working:
const App = () => (
<ChakraProvider
theme={extendTheme({
semanticTokens: {
colors: {
text: {
default: "red.700",
_dark: "red.200"
}
}
}
})}
>
<DarkMode>
<GlobalStyle />
<Heading color="text">Welcome to Chakra + TS</Heading>
</DarkMode>
</ChakraProvider>
);
- Go to ‘https://codesandbox.io/s/intelligent-thompson-563p3?file=/src/index.tsx’
- Heading should be in light red.
Chakra UI Version
1.8.1
Browser
No response
Operating System
- macOS
- Windows
- Linux
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Dark mode with design tokens - UX Collective
Dark & light mode with semantic tokens Choose token names that don't reference a mode (e.g. color-text-primary ) and avoid words like light...
Read more >Dark Mode with Style Dictionary | dbanksdesign - Danny Banks
Using CSS custom properties and having a layer of semantic tokens allows you to not have to re-style every component for light and...
Read more >Color Mode - Chakra UI
Color Mode. Chakra UI comes with built-in support for managing color mode in your apps. By default, most of Chakra's components are dark...
Read more >The hardest part about building dark mode is that people think ...
Join Jacob and Ryhan to understand how Figma shipped one of their most requested features, what barriers you'll face implementing your own, ...
Read more >Color - Reshaped design system
By assigning semantic roles to colors, we achieve predictable theming and dark mode support. We use generic names for the color tokens, which...
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
This is currently a documented edge case.
We are working on a feature to re-attach the css vars to an element to create a new token layer - this would enable the semantic tokens to react to
data-theme
attributes.It was released with a slight twist.
The css variables need a DOM Element to attach them again. The LightMode and DarkMode components do not render an Element, they render only a React Context Provider. Rendering the Element inside of DarkMode would be a breaking change and would introduce a circular dependency.
This code example shows how to use the _dark values of your Semantic Tokens.
We know that this API is not the most intuitive, and we will revisit this API in the future.