diff --git a/README.md b/README.md index fc64336..dc2477c 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,52 @@ This is **Identity System v1** — see [Brand assets](#brand-assets): `next/font/google`. - **Dark theme** — a token-level flip in `globals.css`. It follows `prefers-color-scheme` by default; a stored preference stamps `data-theme` on - `` and wins in both directions (`ThemeToggle` in the navbar, with a - no-FOUC script in the layout). + `` and wins in both directions. Theme state is owned by + `` (`src/components/theme/`) via the `useTheme` hook — the + per-user choice is persisted to localStorage, the OS preference is followed + live until a choice is made, and a no-FOUC script in the layout paints the + initial theme before React hydrates (`ThemeToggle` in the navbar). + +#### Theme usage (light & dark mode) + +`src/lib/theme.ts` is the single source of truth for theme logic: the `Theme` +type, the `THEME_STORAGE_KEY` constant, storage get/set, system-preference +resolution and listening, and the shared no-FOUC `themeScript`. Components read +`resolvedTheme` and call `setTheme` / `toggleTheme` through the `useTheme()` +hook from `src/components/theme/`. + +Two wiring steps are required in the root layout +(`src/app/layout.tsx`) — both are already in place; keep them if you ever +rewrite the layout: + +1. **Paint before React hydrates (no flash).** Insert the exported inline + script in `` via React's safe `