Skip to content
Sign upGet access
MicrointeractionsStretch switchMenu

Stretch switch

A switch whose knob stretches and wobbles as it flips.

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

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/stretch-switch.json

Usage

tsx
import { StretchSwitch } from "@/components/ui/chatcn/stretch-switch"

<StretchSwitch checked={webSearch} onCheckedChange={setWebSearch} aria-label="Web search" />

Props

PropTypeNotes
checked / defaultChecked / onCheckedChangeboolean
colorstringThe flood; default the theme blue

Keyboard

KeyAction
Space / EnterFlip it

Accessibility

  • A real switch button with aria-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.