Installation
Usage
Examples
Basic
A simple toggle button with an icon.With Text
Toggle button with both icon and text.Variants
Sizes
Disabled
Controlled
Component Code
Props
Toggle
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "outline" | "default" | Visual style variant |
size | "sm" | "default" | "lg" | "default" | Size of the toggle |
pressed | boolean | - | Controlled pressed state |
defaultPressed | boolean | false | Default pressed state (uncontrolled) |
onPressedChange | (pressed: boolean) => void | - | Callback when pressed state changes |
disabled | boolean | false | Disables the toggle |
className | string | - | Additional CSS classes |
aria-label | string | - | Accessible label for the toggle |
Accessibility
- Uses the
buttonrole witharia-pressedattribute - Keyboard accessible (Space/Enter to toggle)
- Always include an
aria-labelfor icon-only toggles - Disabled state prevents interaction and is announced to screen readers