Skip to content

Implement full theme system with dark/light/system modes, per-component overrides, and animated transitions #197

@Kingsman-99

Description

@Kingsman-99

Description

Build a complete theme system that supports dark, light, and system-preference modes; allows per-component theme overrides via context; persists preference across sessions; animates theme transitions; and exposes a developer toggle in the dev tools page.

Acceptance Criteria

  • Create src/contexts/ThemeContext.tsx with ThemeProvider and useTheme hook
  • Three modes: "light", "dark", "system" (follows prefers-color-scheme media query)
  • system mode updates automatically if OS preference changes without page reload (via matchMedia listener)
  • Preference stored in localStorage as "theme"; hydrated before first paint to prevent flash of wrong theme (use suppressHydrationWarning pattern for Next.js)
  • Theme toggle component src/components/ThemeToggle.tsx: cycles through light→dark→system; shows icon for each mode; accessible with aria-label and keyboard support
  • CSS transitions on theme change: all background/text/border color changes animate over 200ms (add transition: color 200ms, background-color 200ms to globals.css)
  • Per-component override: <ThemeProvider forcedTheme="dark"> nested anywhere forces dark mode for its subtree only
  • Add toggle to src/app/settings/api/page.tsx and also to src/app/dev/debugger/page.tsx
  • Uses Tailwind darkMode: 'class' strategy — no inline styles
  • Unit tests: system mode responds to matchMedia change, localStorage persistence, forced theme override, no flash on hydration

Context

  • Check tailwind.config.js for current darkMode setting — update if needed
  • Next.js 14 App Router: theme class must be set on <html> element in src/app/layout.tsx
  • suppressHydrationWarning on <html> prevents hydration mismatch from server/client theme difference

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions