Skip to content

UI with light styles still flashes momentarily when dark theme is selected #1290

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
isti115 opened this issue Mar 13, 2025 · 0 comments
Open

Comments

@isti115
Copy link

isti115 commented Mar 13, 2025

With dark mode enabled, the default styles still get applied for a few frames while the page is loading, which results in a quite jarring flash. With the devtools open I can see that the <html> tag initially gets added to the DOM with no data-theme property, then gets set to data-theme="light", and only after does it receive the actual data-theme="dark" value.

There are three approaches that I can think about right now:

  • Loading the saved theme value early enough for it to be available by the time the first frame is rendered
  • If the value is not yet available, respect the prefers-color-scheme value provided by the browser (implementing Switch to dark/light mode based on OS setting #481 would probably solve this as well)
  • Render a gray background until the required information becomes available (this seems like an unnecessary compromise, but would still be better than the current behavior in case you are against implementing either of the two suggestions from above)

Personally I would probably go for the second option, if you'd also be happy with that, I'll send a PR.


P.S. Is it just me, or are code blocks barely visible in the current dark theme? Since everything is already monospace, the font doesn't help in distinguishing them, and their background is so subtle, that I can only see them if I know exactly where to look.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant