# Spaceman React Theme Animation
> Animated theme switching for React with the View Transitions API. Dark mode, color themes and no-flash setups for Next.js, Vite and TanStack Start.
Package: `@space-man/react-theme-animation` (version 3.0.1, ESM only, React 18 or newer, peer dependencies `motion` and `@radix-ui/react-select`).
Install with `npm i @space-man/react-theme-animation`, then pick the provider for your framework:
- Next.js: `ThemeProvider` (or `NextThemeProvider`) in a `'use client'` providers file, hook `useTheme`.
- Vite: `ViteThemeProvider`, hook `useViteTheme`.
- TanStack Start: `TanStackStartThemeScript` in `
` and `TanStackThemeProvider`, hook `useTanStackTheme`.
- Any React app: `SpacemanThemeProvider`, hook `useSpacemanTheme`.
Put the hook's `ref` on the toggle button so the transition starts from it. The providers add the `dark` class to `` and a `theme-` class for color themes.
## Setup guides
- [Next.js setup](https://rta.spaceman.sh/docs/nextjs-setup.md): full setup, props and common issues
- [Vite setup](https://rta.spaceman.sh/docs/vite-setup.md): full setup, props and common issues
- [TanStack Start setup](https://rta.spaceman.sh/docs/tanstack-start-setup.md): full setup, props and common issues
- [Theme transitions](https://rta.spaceman.sh/docs/theme-transitions.md): the seven effects, origins, durations and SVG logos
- [Package README](https://rta.spaceman.sh/docs/readme.md): API reference for the shared hook
## Example apps
- [Next.js guide](https://rta.spaceman.sh/guides/next/)
- [Vite guide](https://rta.spaceman.sh/guides/vite/)
- [TanStack Start guide](https://rta.spaceman.sh/guides/tanstack/)
- [Source of the guides](https://github.com/tonyedgal/spaceman-rta-framework-guides)
## Links
- [GitHub](https://github.com/tonyedgal/spaceman-react-theme-animation)
- [npm](https://www.npmjs.com/package/@space-man/react-theme-animation)