Switch
A toggle switch component built on Base UI.
Installation
First install? Complete the one-time host setup.
Live preview
A toggle for an on/off setting like dark mode. Prefer it over a checkbox when the change takes effect right away, not on submit.
Loading preview…
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | — | Controlled on/off state. |
| defaultChecked | boolean | — | Initial state when uncontrolled. |
| onCheckedChange | (checked: boolean) => void | — | Fires when the user flips the switch. |
| disabled | boolean | false | Dims the switch and blocks interaction. |