Installation
Usage
Props
boolean
Controlled checked state.
boolean
Default checked state for uncontrolled usage.
function
Callback when checked state changes:
(checked: boolean) => voidboolean
Disables the switch.
string
Name attribute for form submission.
string
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