Switch
A toggle for instant settings. The thumb stretches while pressed and settles on a spring curve.
InputsRadix Switch
Playground
Tweak the props, the preview and the code follow.
Props
<div className="flex items-center gap-2.5"> <Switch id="airplane" defaultChecked /> <Label htmlFor="airplane">Airplane mode</Label> </div>
Installation
npx @plumsydev/plum-ui add switchAlso pulls in label automatically.
Usage
import { Switch } from "@/components/ui/switch"<Switch defaultChecked />Examples
Sizes
Settings list
API Reference
Switch
Extends Radix Switch.Root.
| Prop | Type | Default |
|---|---|---|
sizeTrack and thumb size. | "sm" | "default" | "lg" | "default" |
checkedControlled state. | boolean | — |
defaultCheckedUncontrolled initial state. | boolean | false |
onCheckedChangeCalled when toggled. | (checked: boolean) => void | — |
Notes
- The spring is pure CSS (
ease-spring, alinear()easing), so it costs nothing at runtime.