Color themes from any button
createColorThemeToggle returns a click handler that swaps the palette with the same view transition. The reveal starts from the button you press.
Next.js App Router guide
How this is wired
- src/components/theme/theme-provider.tsxA 'use client' wrapper around ThemeProvider. It lists the color themes and injects the pre-hydration script, so the page never flashes the wrong theme.
- src/app/layout.tsxStays a server component. It renders the provider and sets suppressHydrationWarning on <html>, because the script adds the theme class before React loads.
- src/components/theme/ThemeToggle.tsxA toggle built on useThemeAnimation. The ref marks the button as the origin of the circle reveal.
- src/app/globals.cssLight, .dark and .theme-* variables, plus an @source line so Tailwind scans the package for the prebuilt controls.