Switch

Form

Toggles a binary setting on or off.

npx shadcn@latest add switch

Default

Preview
Live
tsx
1<div className="flex items-center gap-3">
2 <Switch defaultChecked />
3 <Label>Airplane mode</Label>
4</div>

API reference

All props of the underlying Base UI primitive are forwarded. The table below documents the Shelf-specific props.

PropTypeDescription
checkedbooleanControlled checked state.
onCheckedChange(checked: boolean) => voidCalled when the switch toggles.
disabledbooleanPrevents interaction.