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.json

Or, 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

Component props
PropTypeDefaultNotes
checked / defaultCheckedbooleanfalsetrue = dark. Controlled or uncontrolled.
onCheckedChange(dark: boolean) => void—Fires inside the view transition, so state updates are captured in the reveal.
scopeRefRefObject<HTMLElement>—Element that receives the dark / light class on toggle.
applyToRootbooleanfalseAlso toggle the class on <html> for a site-wide switch.
size'md' | 'lg''md'Visual size; the hit area is always at least 44px.
revealScalenumber1Multiplier for the reveal circle radius.
onRevealEnd(dark: boolean) => void—Called when the transition completes.
aria-labelstring'Dark mode'Accessible name of the switch.

Dependencies

  • motion

See all 15 Toggles components