Component
Switch is used to toggle between two states on and off. It is commonly used in settings panel, forms and any other place where a user needs to enable or disable feature.
View component changelogpreview
Root component for the Switch component.
| Prop | Type | Default |
|---|---|---|
children | React.ReactNode | null |
customRootClass | string | '' |
color | string | '' |
variant | string | -- |
size | string | -- |
defaultChecked | boolean | false |
checked | boolean | -- |
onCheckedChange | function | -- |
disabled | boolean | false |
required | boolean | false |
name | string | -- |
value | string | -- |
asChild | boolean | false |
Thumb component for the Switch component.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | -- |
children | ReactNode | -- |
| Shortcut | Description |
|---|---|
Tab | Moves focus to the switch. |
Space | Toggles the checked state. |
Enter | Toggles the checked state. |
| Reference | What Rad UI follows |
|---|---|
Uses switch semantics with aria-checked to expose the current on or off state. |