Skip to content

Harden next-themes hydration and the theme toggle experience #527

Description

@grantfox-oss

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).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions