Sleep

No dependencies
Code format

Install with shadcn

Needs a free account token. Get a token

npx shadcn@latest add @movin/toggle-sleep

About this component

Do not disturb. Off, the thumb holds a bell; switching on slides it across as the bell swings away and a moon turns in to replace it, the track goes night-dark with two stars, and little z's keep drifting up off the moon while it is on. Pure CSS on a native switch.

Triggers

  • Click
  • State change
  • Icon
  • Icon swap

Techniques

  • Keyframes
  • SVG
  • CSS transition

Difficulty

Intermediate

Accessibility

Keyboard and screen readers

Native checkbox with role="switch" inside a <label>. The visible label text names it. Focus ring on the visual via :focus-visible.

Reduced motion

The change is instant.

Use it in anything you build, commercial and client work included. Licence

More toggles

See all
ZipperGet code
FlipGet code