Pull Cord, animated React component
A light switch on a cord: a small verlet rope you grab by its bead, pull past its slack and let go to toggle the light. The panel lights up or goes dark and the cord swings and settles; Enter or Space tugs it from the keyboard.
- Pro
- Inputs & Controls
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
Lights off.
Pull the cord.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| defaultOn | boolean | false | Whether the light starts on. |
| onChange | (on: boolean) => void | — | Called with the new state when the user pulls the cord or presses Enter/Space on it. |
| onText | string | "Lights on." | Headline while the light is on. |
| offText | string | "Lights off." | Headline while the light is off. |
| hint | string | "Pull the cord." | Small line under the headline. |
| className | string | — | Extra classes for the 320px-wide outer wrapper. |
| autoplay | boolean | false | Tugs the cord every 2.6s until someone grabs it. |