Toggle Sidebar B
AppearanceLight & dark mode D

Squish Switch

Drag-scrubbable switch whose thumb stretches by how fast it moves, flips at the midpoint and squashes against the track end on a flick.

Default

Tap the switch, or drag the thumb and flick it to either end.

Dark previewReplay previewOpen in new tab

Customize

Track
Track On
Thumb
Thumb On
Width76px
Height38px
Radius19px
Speed50
Stretch36
Hover Scale1.035
Color Fade320ms

API Reference

SquishSwitch

PropTypeDefaultDescription
checkedbooleanundefinedControlled state, bound with v-model:checked. Leave it out to let the switch keep its own.
defaultCheckedbooleanfalseInitial state when uncontrolled.
labelstring''A label beside the switch, wired to it.
disabledbooleanfalseDimmed and inert.
trackColorstring'#27272a'The track while off.
trackOnColorstring'#f5f5f5'The track while on.
thumbColorstring''The thumb while off. Empty mixes the on colour faintly into the track.
thumbOnColorstring''The thumb while on. Empty uses the off track colour.
widthnumber76Track width in px.
heightnumber38Track height in px. The thumb and its inset follow.
radiusnumber19Track corner radius in px, capped at half the height.
speednumber50Stiffness of the settle spring, 0 to 100. Low is lazy, high is snappy.
stretchnumber36How much the thumb lengthens with speed, 0 to 100. It narrows to keep its area.
hoverScalenumber1.035The thumb swells to this on hover.
colorDurationnumber320The colour cross-fade, in ms.
ariaLabelstring-Accessible name when there is no label.
idstring-Id for the switch button; the label uses it.
EventDescription
changeEmitted with the new boolean on a tap, a drag past the middle or a key.
update:checkedEmitted alongside change, for v-model:checked.

Accessibility

Keyboard shortcuts and ARIA behavior.

Shortcut Description
Space + EnterToggles the switch.
EscapeCancels a drag and restores the state from before the press.
  • Rendered as a button with role switch and aria-checked. The label is linked through for and id.
  • With prefers-reduced-motion the thumb jumps to its end and no longer stretches.