Components
Toggle
Immediate-effect boolean switch. Use instead of Checkbox when the action takes effect immediately without form submission.
Import
Usage
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Visible label |
description | string | — | Secondary label text |
size | 'sm' | 'md' | 'lg' | 'md' | Toggle size |
className | string | — | Additional CSS classes |
...rest | InputHTMLAttributes | — | All native input attributes |
When to use Toggle vs Checkbox
| Toggle | Checkbox |
|---|---|
| Immediate effect (dark mode, notifications) | Form submission required |
| Single independent setting | Part of a list (select all, multi-select) |
| Mobile-like on/off switch aesthetic | Traditional form feel |
Controlled
Accessibility
- Renders as
<input type="checkbox">with a custom visual indicator - Space toggles the switch
aria-checkedreflects the current state- Label associated via
htmlFor - Respects
disabledattribute