-
Notifications
You must be signed in to change notification settings - Fork 142
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
White content flash on dark mode #376
Comments
Myself and @Raiden0456 are looking to fix this sometime soon |
This was fixed for a while, but now it's a black flash on light mode instead... |
Yes @mr-cheff made dark mode the default mode, so now the page loads dark mode my default first. However, he also deferred the script that loads the theme from local storage, which increases the flash time. |
You have the following code in :root {
--zen-paper: #f2f0e3;
--zen-dark: #202020;
--zen-muted: rgba(0, 0, 0, 0.05);
&[data-theme='dark'] {
--zen-paper: #202020;
--zen-dark: #f2f0e3;
--zen-muted: rgba(255, 255, 255, 0.05);
}
} Couldn't this be change to use Code then can be changed to first try browser color pref, then JS would check Note that this is just a band-aid solution and not a proper replacement for light/dark mode system. |
I don't think this is the case. MDN docs say that browsers ignore the I'm actually curious why the flash happens. I'm currently re-making a website for another open-source project. I also use Astro, and I also use a similar inline script for switching the theme, however, I don't seem to have the same issue with the theme flash. In fact, I forked this repository and deployed it as is, without any changes, and I don't seem to have this issue there either. Could this somehow be related to the hosting? |
2024-12-20.15-45-08.mp4
As in the video, bright flash can be seen, even while loading dark mode.
How this could be fixed is up to you, and how do you generate website (SPA, Hybrid or just server rendered). Maybe some cookie, or just color mode detection in plain css which is prefetched. From what I have seen, now, it stores color mode in localStorage, which needs js to access, which in turn does only get interpreted after some milliseconds (but still produces noticeable flash on dark mode).
The text was updated successfully, but these errors were encountered: