Toggle
formSpring-physics animated switch with accessible label and multiple sizes.
import { Toggle } from '@/components/forge'Preview
Toggle
Code Example
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
checked | boolean | - | Yes | Controlled on/off state |
onChange | (checked: boolean) => void | - | Yes | Callback when toggled |
label | string | - | No | Accessible label text |
size | 'sm' | 'md' | 'md' | No | Toggle size |
disabled | boolean | false | No | Disables interaction |
Variants
smmd
Accessibility
- Uses role="switch" with aria-checked
- Label is associated via aria-label or visible text
- Animation respects prefers-reduced-motion