Skip to content
Components56 / 118

Theme Toggle

A dark / light switch in monospaced capitals, split into two equal halves with a moon and a sun. Hover the other half and a pill blooms out of your cursor, a circle that swells to fill the half, while a band of glitch glyphs sweeps across its label and decodes it; leave and it gathers back into your cursor. Click and the selection slides across into it, and the moment it lands every colour flips and the page turns over to the other theme. A proper radio group with arrow keys.

Glitch decodeCursor bloomTheme flipRadio groupGSAPReduced-motion safe
Hover the other halfClick to turn the page over

Tweak

LIVE

Labels

Colours

#0e0c0a
#f8f9ef
60px

Props

10 props
  • value"dark" | "light"
    Controlled theme.
  • defaultValue"dark" | "light"
    Initial theme when uncontrolled.default "dark"
  • onValueChange(theme) => void
    Called with the new theme once the selection has landed.
  • applyToDocumentboolean
    Set data-theme and color-scheme on <html> when it flips.default false
  • labels{ dark: string; light: string }
    The two labels.default Dark / Light
  • inkstring
    The dark colour.default "#0e0c0a"
  • paperstring
    The light colour.default "#f8f9ef"
  • sizenumber
    Height, px.default 60
  • aria-labelstring
    Accessible name of the group.default "Theme"
  • classNamestring
    Extra classes.