Problem
The current theme system uses next-themes and ThemeToggle, but hydration mismatches and theme flash are common risks with this pattern.
Goals
- Harden
components/theme-toggle.tsx and app/layout.tsx for stable client/server rendering.
- Ensure the theme is correctly persisted across browser reloads and server-rendered pages.
- Make the toggle fully keyboard accessible and announce the active theme state.
- Add a fallback for browsers that do not support local storage.
Acceptance criteria
- The theme preference persists across refreshes and custom routes.
- No hydration warnings occur when switching themes or loading pages.
- Keyboard and screen-reader users can use the toggle successfully.
- The only
ThemeToggle icon state is the active theme (no flicker or incorrect state before mount).
Problem
The current theme system uses
next-themesandThemeToggle, but hydration mismatches and theme flash are common risks with this pattern.Goals
components/theme-toggle.tsxandapp/layout.tsxfor stable client/server rendering.Acceptance criteria
ThemeToggleicon state is the active theme (no flicker or incorrect state before mount).