Toggle
stableA two-state button that can be on or off.
Basic usage
Examples
Outline variant
The outline variant pairs well with text editor toolbars.
Toggle variants and sizes
Use Toggle for formatting controls, filters and icon buttons.
Semantic colors
Color prop sets the pressed-state background and text for semantic toggles.
Features
- Controlled or uncontrolled.
- Two variants, three sizes.
Installation
bash
pnpm dlx structyl add toggleAPI Reference
Toggle
A two-state pressable button.
| Prop | Type | Default |
|---|---|---|
| pressed | booleanControlled pressed state. | — |
| defaultPressed | booleanInitial pressed state. | — |
| onPressedChange | (pressed: boolean) => voidCalled when toggled. | — |
| variant | 'default' | 'outline'Visual style. | 'default' |
| size | 'default' | 'sm' | 'lg'Control size. | 'default' |
| disabled | booleanDisable the toggle. | — |