Skip to content

fix: prevent dark theme flash#22

Open
KartikXx wants to merge 1 commit into
ramxcodes:masterfrom
KartikXx:codex-fix-dark-theme-flash
Open

fix: prevent dark theme flash#22
KartikXx wants to merge 1 commit into
ramxcodes:masterfrom
KartikXx:codex-fix-dark-theme-flash

Conversation

@KartikXx
Copy link
Copy Markdown

Summary

Fixes the white flash users see when dark mode is enabled and they navigate between pages.

The issue happened because the early theme script was reading localStorage.theme, while the app actually saves the theme under notes-buddy-theme. Because of that mismatch, pages could render light first and switch to dark after hydration.

What changed

  • Applied the saved theme before first paint using Next's beforeInteractive script strategy.
  • Used the same notes-buddy-theme key in the init script and theme provider.
  • Handled dark, light, and system themes consistently.
  • Updated color-scheme so browser-native UI matches the active theme.
  • Prevented the provider from briefly falling back to light mode after hydration.
  • Made the theme toggle a proper accessible button.

Validation

  • git diff --check passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant