Rocker

No dependencies
Code format

Install with shadcn

Needs a free account token. Get a token

npx shadcn@latest add @movin/toggle-rocker

About this component

A wall light switch. The rocker paddle tips in 3D from one end to the other with a firm snap, its shading flipping as it turns toward the light, and a small LED on the plate glows when it is on. Pure CSS on a native switch.

Triggers

  • Click
  • State change
  • 3D

Techniques

  • 3D transform
  • Perspective
  • 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
RotaryGet code
SeesawGet code
ShifterGet code
SleepGet code