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.
TanStack Start guide
How this is wired
- src/routes/__root.tsxRenders TanStackStartThemeScript in the head, so the theme class is on <html> before the page paints, and wraps the app in TanStackThemeProvider.
- vite.config.tsTurns on prerendering. Every route is written to static HTML at build time, so the guide needs no server.
- src/components/theme/ThemeToggle.tsxA toggle built on useThemeAnimation. The ref marks the button as the origin of the circle reveal.
- src/styles.cssLight, .dark and .theme-* variables. With systemThemeMode="css", a .system class follows the OS setting through a media query.