Icon
Markup where the component goes, CSS in your stylesheet, script before </body>. In Vue, Svelte or Angular, call initToggleIcon(el) on the mounted element instead.
Paste into Claude, ChatGPT or Cursor after filling in {{USER_STACK}}, {{USER_STYLING}} and {{USER_CONSTRAINTS}}. Neutral keeps the greys you see here; Match my project asks the model to map them onto your own colour tokens.
Install with shadcn
Needs a free account token. Get a token
npx shadcn@latest add @movin/toggle-iconAbout 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
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