Stretch switch
A switch whose knob stretches and wobbles as it flips.
On this page
Flip a tool on or off and the knob stretches as it travels and wobbles at the wall, while the colour floods in behind it.
Flip it and the knob's leading edge runs ahead while the trailing edge catches up, so it stretches as it travels, hits the far wall hard and wobbles back to round. The colour floods in behind it through an ordered dither with a wavering front, rather than fading. Press it and the knob squashes toward where it is going; drag it and it follows your finger.
Installation
Usage
import { StretchSwitch } from "@/components/ui/chatcn/stretch-switch"
<StretchSwitch checked={webSearch} onCheckedChange={setWebSearch} aria-label="Web search" />Props
| Prop | Type | Notes |
|---|---|---|
checked / defaultChecked / onCheckedChange | boolean | |
color | string | The flood; default the theme blue |
Keyboard
| Key | Action |
|---|---|
Space / Enter | Flip it |
Accessibility
- A real
switchbutton witharia-checked; give it a label.
Motion
- The leading edge springs stiff (430) and the trailing edge soft (125); the wall kick sets off the wobble. Reduced motion: it moves without the stretch and the flood steps.