question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chakra UI Dark Mode White Screen Flash

See original GitHub issue

When I run the nextjs-typescript example when you click on different pages on Dark Mode the screen will flash with a white before loading the page. It’s not as bad as typing in the URL manually but it’s still quite jarring. Any ideas how I can fix this?

Thanks!

Steps to reproduce:

Clone nextjs-typescript

  • npm i framer-motion
  • npm run dev
  • Click on View Properties

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
samchungycommented, Nov 7, 2020

I think I’ve fixed it, if you import Chakra in _app.tsx it seems to fix it.

import {Chakra} from '../Chakra';

and then wrap the component in it:

<Chakra><Component {...pageProps} /></Chakra>

0reactions
NxRootcommented, Dec 18, 2022

For React Users (no SSR)

Add this script below the body of index.html

<script>
    function useColor(light="white", dark="#171923"){
      return window.localStorage.getItem("chakra-ui-color-mode") === "dark" ? dark : light
    }
    document.body.style.background = useColor();
</script>

You might want to specify the correct color for each mode.

Read more comments on GitHub >

github_iconTop 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 >
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 >
Color Mode - Chakra UI
When you use the ChakraProvider at the root of your app, you can automatically use color mode in your apps. By default, most...
Read more >
Fixing the dark mode flash issue on server rendered websites
There's one last update to be done: updating the toggle light/dark mode function. We need to add a few lines of code to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found