Forms/Switch
Switch
A toggle switch for boolean settings. Animated thumb with spring physics, fully accessible with keyboard and screen reader support.
import { Switch } from "@animui/ui"Basic
Sizes
Disabled
Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | false | Whether the switch is on. |
defaultChecked | boolean | false | Initial checked state (uncontrolled). |
onChange | (checked: boolean) => void | — | Called when the switch is toggled. |
label | string | — | Visible label rendered next to the switch. |
description | string | — | Secondary description text rendered below the label. |
size | "sm" | "md" | "lg" | "md" | Controls the size of the toggle track and thumb. |
disabled | boolean | false | Prevents interaction and applies reduced opacity. |
name | string | — | HTML name attribute for form submission. |
className | string | — | Additional classes for the wrapper element. |
Accessibility
- ✓Renders with
role="switch"andaria-checked. - ✓Toggleable with
Spacekey when focused. - ✓The
labelprop is associated viaaria-label.