Skip to content
Pinky UI

Elastic Toggle

A preference switch whose track and thumb redistribute together and settle with an explicit On/Off state.

  • controls
  • elastic
  • jelly
  • switch
  • toggle
  • form
  • control

Quick usage

usage
import { ElasticToggle } from "@pinky-ui/components";

<ElasticToggle
  label="Reduced motion"
  onCheckedChange={setEnabled}
/>

Presets

Subtle

Almost no deformation.

stretch={0.2}

Soft

The default.

stretch={0.5}

Playful

Rubbery. Use once.

stretch={1}

Install

Add @pinky-ui/components as a dependency, or use the CLI to copy this component's source directly into your project — no dependency to manage, fully editable.

shell
npm install @pinky-ui/components

Prefer to run the whole repository locally instead?

repository
git clone https://github.com/florash/Pinky-UI.git
cd Pinky-UI
npm install
npm run dev

Props

PropTypeDefaultDescription
checkedbooleanControlled state. Omit to let the toggle own it.
defaultCheckedbooleanfalseInitial state when uncontrolled.
onCheckedChange(checked: boolean) => voidCalled on every change.
labelstringVisible label. Without it, pass aria-label.
stretchnumber0.5How much the thumb deforms while travelling, 0–1.
disabledbooleanfalseDisables the control.

Accessibility

  • role=switch with aria-checked — announced as on/off, not as a checkbox.
  • Operable with Space and Enter; the visible label toggles it too.
  • State is carried by position and colour, never by the animation alone.
  • Disabled state is conveyed to assistive technology and blocks interaction.

Reduced motion

With prefers-reduced-motion: reduce, the thumb moves instantly with no stretch. The control reads and behaves identically.

When to use

  • Settings and preference panels
  • Instant-effect options with no save step

When not to use

  • Anything needing a confirm step — use a checkbox and a submit
  • Destructive switches, where playfulness undercuts the weight of the action