Toggle
A button that stays pressed: bold on, watching on. Two variants and three sizes. For a set of them, use Toggle group.
Installation
Or with the shadcn CLI, from the registry:
Usage
Variants and sizes
default is flat until pressed, then takes the accent grey; outline has the input's border; soft takes a wash of the
primary when pressed, so the on state reads as the brand colour (with a border in Iwa). Sizes are sm, default and
lg, the village's control heights.
Villages
Pressed, it takes the accent surface; the outline variant keeps the village's shadow, like an outline button.
Accessibility
- A
<button>witharia-pressed; Space and Enter toggle it. - An icon-only toggle needs an
aria-label, which should not change with the state.
API reference
The props of Base UI's Toggle (pressed, defaultPressed, onPressedChange, disabled), plus:
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "soft" | "default" |
size | "sm" | "default" | "lg" | "default" |
toggleVariants({ variant, size }) returns the same classes.