Switch
Toggle switch built on Radix UI Switch. Ideal for binary on/off settings such as enabling features or toggling modes.
Basic
Preview
Default Checked
Preview
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | - | Label text displayed next to the switch. |
| defaultChecked | boolean | false | Default checked state for uncontrolled usage. |
| checked | boolean | - | Controlled checked state. |
| onCheckedChange | (checked: boolean) => void | - | Callback fired when the checked state changes. |
| disabled | boolean | false | Whether the switch is disabled. |
| className | string | - | Additional CSS classes. |
Accessibility
- Built on Radix UI Switch which provides full WAI-ARIA switch role compliance
- Label is associated with the switch for screen reader support
- Togglable via
Spacekey when focused - On/off state is conveyed to assistive technology via
aria-checked - Disabled state prevents interaction and is communicated to assistive technology