Skip to content
Components59 / 118

Glass Orb Toggle

A dark / light switch with a clear glass orb, larger than its pill, resting over one end. Through the glass you see the pill magnified and bent toward the rim, with a curved studio reflection under its crown and a bright fresnel edge. Switch it and the orb glides across on a spring, squashing a little along its path; the glowing moon inside turns into the sun, the labels trade places and the pill lights up. Drag it, throw it, and it leans after your cursor.

Glass shaderThree.jsSpring physicsDraggableTheme switchGSAP
Click or drag the orbMove near it: the glass leans

Tweak

LIVE

Labels

Size

72px

Props

8 props
  • value"dark" | "light"
    Controlled theme.
  • defaultValue"dark" | "light"
    Initial theme when uncontrolled.default "dark"
  • onValueChange(theme) => void
    Called the moment it is switched.
  • applyToDocumentboolean
    Set data-theme and color-scheme on <html> when it switches.default false
  • labels{ dark: string; light: string }
    Shown on the side the orb isn't on.default Dark / Light
  • sizenumber
    Orb diameter in px; the pill is sized from it.default 64
  • aria-labelstring
    Accessible name.default "Light mode"
  • classNamestring
    Extra classes.