Switch
Toggles a setting that takes effect immediately.
@rivetui/switchPreview
Explore each composition interactively, then open its code in the same context.
With supporting text
Place the immediate setting beside a clear label and concise consequence.
Route traffic to a healthy region when the primary is unavailable.
States
On, off, and disabled switches retain a consistent target and alignment.
Validation
Use semantic invalid state and a connected error when a switch is required.
Enable this control before launch.
Registry
Installation
Add the component source and its declared dependencies with the shadcn CLI.
Install component
bunx --bun shadcn@latest add @rivetui/switchPublic interface
API reference
Component-specific props are listed here. Native element and Base UI props continue to pass through.
| Prop | Type | Default |
|---|---|---|
checked | boolean | — |
defaultChecked | boolean | false |
onCheckedChange | (checked: boolean, details) => void | — |
disabled | boolean | false |