Basic usage
Props
boolean
The controlled checked state of the switch.
boolean
The default checked state for uncontrolled usage.
(checked: boolean) => void
Callback fired when the checked state changes.
boolean
Whether the switch is disabled.
boolean
Whether the switch is required.
string
The name of the switch input for form submission.
string
The value of the switch input when checked.
'small' | 'large'
default:"'large'"
The size of the switch.
string
Additional CSS classes to apply to the switch.
Controlled switch
Uncontrolled switch
Size variants
Disabled state
With labels
With descriptions
With form integration
Required switch
Settings panel example
Accessibility
- Built on Base UI Switch primitive with full accessibility support.
- Proper ARIA attributes including role=“switch” are automatically applied.
- Supports keyboard navigation with Space to toggle.
- Checked state is properly communicated to screen readers.
- Works seamlessly within forms with proper name/value attributes.
- Label association ensures the entire label area is clickable.