Liquid Toggle
betaA switch whose knob squashes like a droplet as it travels, and can be dragged across.
- Forms
- 1 file
- 3 npm packages
- Accessibility notes
- Animates with motion
Loading the example…
pnpm dlx @dowel-ui/cli add liquid-togglenpm packages installed: class-variance-authority, motion, radix-ui.
import { LiquidToggle } from "@/components/ui/liquid-toggle";Default
Gallery
<LiquidToggle>
| Prop | Type | Default |
|---|---|---|
size | "sm" | "md" | "md" |
speedSpring stiffness, 0–100: how quickly the knob crosses. | number | 50 |
stretchVelocity squash and stretch, 0–100. 0 keeps the knob a rigid circle. | number | 36 |
stroke | boolean | — |
Every prop of Radix UI’s Switch.Root, plus className.
Built on the Radix switch primitive: role="switch" with aria-checked, toggled by click, Space or Enter, with a visible focus ring (missing in the source) and a hidden input inside forms. It has no visible label, so name it with aria-label or a <label>. Dragging the knob is a pointer convenience; releasing a drag never also counts as a click. Under reduced motion the knob jumps and never deforms.
8/8
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — does not apply
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — does not apply
- No fixed widths — passes