Fan

No dependencies
Code format

Install with shadcn

Needs a free account token. Get a token

npx shadcn@latest add @movin/toggle-fan

About this component

A desk fan with its own switch. Switching on, the blades spin up with real momentum (and a motion-blur disc fades in as they get fast); switching off, they coast down and come to rest wherever they happen to stop, rather than snapping back.

Triggers

  • Click
  • State change
  • Continuous

Techniques

  • requestAnimationFrame
  • CSS variables
  • Filter
  • SVG

Difficulty

Advanced

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 and the script skips its animation.

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

More toggles

See all
FaucetGet code
Split FlapGet code
Neon SignGet code
PadlockGet code