Switch
Toggle for boolean settings. Use the wrapper or compose SwitchRoot + SwitchThumb with a raw base-ui Root.
Switch
base-ui docs ↗Toggle for boolean settings. Renders a track with a sliding thumb and
an optional label. Wraps @base-ui/react Switch.
| Prop | Type | Default |
|---|---|---|
| checked | boolean | — |
Controlled checked state. | ||
| defaultChecked | boolean | — |
Initial checked state (uncontrolled). | ||
| disabled | boolean | — |
Prevent interaction. | ||
| required | boolean | — |
Mark the field as required for form validation. | ||
| name | string | — |
HTML name attribute for form submission. | ||
| value | string | — |
HTML value attribute for form submission. | ||
| onCheckedChange | ((checked: boolean, eventDetails: unknown) => void) | — |
Called when checked state changes. | ||
| children | ReactNode | — |
Label content rendered next to the switch. | ||
| id | string | — |
Override the auto-generated element id. | ||
| className | string | — |
Styled Parts
base-ui docs ↗Pre-styled wrappers around the corresponding base-ui parts. All base-ui props are forwarded.
CSS Class Names
Available as keys on the SwitchStyles object. Each key maps to a hashed CSS module class name at runtime.
labelrootthumbthumb-track