[SSR] Color mode flash
See original GitHub issueIt looks like the changes we made to fix color mode in 1.0.0-rc.3
worked for static generation, but also broke SSR.
See https://personal-react-boilerplate.now.sh/ for an example.
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (8 by maintainers)
Top Results From Across the Web
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 >Chakra UI colormode issue (white flashes) - TrueQ
WIth Chakra UI there is an issue which results in white flashes when reloading/loading a statically rendered page with their dark mode ......
Read more >Fixing the dark mode flash issue on server rendered websites
Bringing a proper solution to dark mode flashing without an ugly hack. ... so there's no way to know which color theme the...
Read more >Flashless Chakra UI - npm
This library contains all the tools necessary to implement Chakra UI color modes on statically rendered websites without the flash.
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
Update: I turned the technique above into an NPM library to make it simple to implement. You can read more about that effort over here.
I was able to accomplish a non-flashing color mode implementation with Chakra using CSS variables and a method like the one in @joshwcomeau’s article on the subject. I defined a bunch of CSS variables based on theme colors in a pre-body script, and changed my Chakra theme to use those variables instead of theme keys.
Here’s a gist with the relevant parts. I’ve added a few comments in there explaining some of the things I do. I poked around Bumbag and noticed they were using color variables in a similar way, from what I could tell.
I can help build this feature if the Chakra team approves of this technique, and it doesn’t negatively affect other uses of the library. It seems pretty straightforward (define CSS variables and use those in the default theme), but I could be missing something. Happy to discuss! 🙂