Theme Reveal Toggle
A sky-to-night switch: the sun rolls behind a crescent, clouds give way to stars, and the theme change blooms out of the switch as a circular View Transition reveal. Instant swap under reduced motion.
Try it: Click, or focus and press Space — the new theme spreads out from the switch.
Installation
Install with the shadcn CLI:
npx shadcn@latest add https://www.framekitui.live/r/theme-reveal-toggle.jsonOr, with the @framekit namespace registered: npx shadcn@latest add @framekit/theme-reveal-toggle. You can also copy the source into components/ui/theme-reveal-toggle.tsx (view on GitHub).
Usage
import { ThemeRevealToggle } from '@/components/ui/theme-reveal-toggle'Props
| Prop | Type | Default | Notes |
|---|---|---|---|
checked / defaultChecked | boolean | false | true = dark. Controlled or uncontrolled. |
onCheckedChange | (dark: boolean) => void | — | Fires inside the view transition, so state updates are captured in the reveal. |
scopeRef | RefObject<HTMLElement> | — | Element that receives the dark / light class on toggle. |
applyToRoot | boolean | false | Also toggle the class on <html> for a site-wide switch. |
size | 'md' | 'lg' | 'md' | Visual size; the hit area is always at least 44px. |
revealScale | number | 1 | Multiplier for the reveal circle radius. |
onRevealEnd | (dark: boolean) => void | — | Called when the transition completes. |
aria-label | string | 'Dark mode' | Accessible name of the switch. |
Dependencies
motion
Related Toggles components
- Pull-Cord Lamp Toggle
A pendant lamp switched by its pull cord: drag the bead down until it clicks, the cord snaps back elastically and sways, the shade rocks on its wire and the bulb warms into a cone of light with…
- Weather Vane Toggle
Vane pivots; grain shifts with wind.
- Watchful Eye Toggle
A soft eye opens and closes; the pupil tracks when open.
- Tideglass Toggle
Waterline rises and falls in a glass pane.
- Day Night Capsule
Illustrated mini sky that morphs day↔night.
- Petal Circuit Toggle
Petals fold inward to complete a circuit.