Overview
Off
On
Disabled off
Disabled on
Installation
Usage
Variants
Basic
Enable dark mode
On by Default
Email notifications
With Description
Auto-save
Automatically save your work every 5 minutes.
Label on Left
Show sidebar
Disabled
Beta features
Always-on feature
Controlled
API Reference
boolean
Controlled checked state.
boolean
default:"false"
Uncontrolled initial state.
(checked: boolean) => void
Callback fired when the switch state changes.
string
Label text displayed next to the switch.
string
Supporting description shown below the label.
string
default:"right"
Position of the label relative to the switch. Values:
left Β· rightboolean
default:"false"
Disables the switch and applies the disabled visual style.
string
Additional Tailwind classes for custom overrides.
Accessibility
- Switch uses
role="switch"witharia-checkedfor proper screen reader announcement - Label is associated via
htmlFor/idβ clicking the label also toggles the switch descriptionis linked viaaria-describedbydisableduses the nativedisabledattribute, removing the element from tab order- Space bar toggles the switch when focused β follows ARIA switch pattern
- Focus ring meets WCAG 2.1 AA contrast requirements
Doβs & Donβts
Do
- Use Switch for settings that take immediate effect (dark mode, notifications)
- Always provide a descriptive label β never a switch alone
- Use
descriptionto clarify the impact of toggling - Place switches in settings panels or preference pages
Don't
- Donβt use Switch inside a form that requires submission β use Checkbox instead
- Donβt use Switch for multi-select scenarios β use Checkbox Group
- Donβt use ambiguous labels like βOn/Offβ β describe what is being toggled
- Donβt disable without explaining why in nearby helper text