Pull Cord
Install with shadcn
Needs a free account token. Get a token
npx shadcn@latest add @movin/button-pull-cordAbout this component
A lamp switch: a cord hangs from the button with a bead on the end. Drag the bead down past the trigger point and let go to turn it on; the cord springs back and swings like a pendulum. Clicking the button itself toggles it too and tugs the cord, so keyboards get the same switch.
Triggers
- Click
- Spring
- State change
- Glow
Techniques
- SVG
- Spring
- requestAnimationFrame
- Event position
- State machine
Difficulty
Advanced
Accessibility
Keyboard and screen readers
A real <button> with aria-pressed carries the state; the cord and bead are aria-hidden extras.
Reduced motion
The cord never swings.
Use it in anything you build, commercial and client work included. Licence