Installation
Usage
Props
Controlled checked state.
Default checked state for uncontrolled usage.
Callback when checked state changes:
(checked: boolean) => voidDisables the switch.
Name attribute for form submission.
Value attribute for form submission.
Examples
Basic Usage
With Label
Controlled
Disabled
Styling
The switch consists of:- Root: The track background that changes color when checked
- Thumb: The circular indicator that slides when toggled
data-checked attribute.
Accessibility
- Built on @base-ui/react Switch primitive
- Keyboard accessible (Space/Enter to toggle)
- Focus visible ring with offset
- Proper ARIA role and attributes
- Screen reader announces state changes