Icon

No dependencies
Code format

Install with shadcn

Needs a free account token. Get a token

npx shadcn@latest add @movin/toggle-icon

About this component

A dark-mode toggle pill with a sun/moon icon swap. The track shifts from a deep charcoal gradient to a light gray gradient. The knob slides with spring and crossfades between a moon (off) and a sun with rays (on). Each icon counter-rotates 90° as it enters/exits.

Triggers

  • Click
  • State change
  • Icon
  • Spring

Techniques

  • Transform only
  • Gradient

Difficulty

Beginner

Moves on

Its code uses this curve. Open one to see it plotted and tune it.

Accessibility

Keyboard and screen readers

role="switch" + aria-checked + dynamic aria-label ("Switch to dark/light mode").

Reduced motion

Transitions skipped under prefers-reduced-motion.

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

More toggles

See all
LiquidGet code
PowerGet code