Switch
On/off toggle.
Installation
Usage
Examples
States
On, off, and disabled side by side.
With description
Pair the label with helper text for longer explanations.
Settings list
Stacked toggle rows separated by dividers.
API reference
Switch
| Prop | Type | Default |
|---|---|---|
checkedControlled checked state. Use with onCheckedChange. | boolean | - |
defaultCheckedInitially checked when uncontrolled. | boolean | false |
onCheckedChangeCalled when the switch is flipped. | (checked: boolean) => void | - |
disabledIgnore user interaction. Renders at half opacity. | boolean | false |
readOnlyShow state without allowing flips. | boolean | false |
requiredRequire the switch to be on before form submit. | boolean | false |
nameIdentifies the field when the form is submitted. | string | - |
valueValue submitted with the form when on. | string | - |
renderPolymorphic render prop. Use to render a custom element. | ReactElement | ((props) => ReactNode) | - |
classNameAdditional classes merged with the default switch styles. | string | - |