Use the hook directly
Each button below calls useThemeAnimation on its own, with a different reveal: a circle, a blurred circle and a directional slide. Pick a slide direction, then toggle.
Circle Theme:
Blur Circle Theme:
Slide Theme:
Slide direction:
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.