Toggle
A two-state button that stays pressed. Use it for a setting that takes effect immediately, not as a substitute for a checkbox in a form.
Purpose
A Toggle is a button that holds its pressed state — formatting controls, view options, filter
chips. It keeps button semantics (aria-pressed), so it reads as "this button is on", not "this
field is ticked".
Use it for
- Formatting controls in a toolbar (bold, italic)
- View options that apply immediately (compact rows)
- Filter chips that narrow a list in place
Reach for something else
- An instant on/off setting → Switch
- A value submitted with a form → Checkbox
- A one-shot action → Button
- One of an exclusive set → Tabs or Radio group
Icon toggles
The classic toolbar use. Icon-only toggles must carry an aria-label.
Outline, with label
The outline variant carries a border and works as a filter chip with a text label.
Sizes
Three sizes matching Button's heights; each keeps a square minimum width for icon-only use.
States
Pressed is --accent fill; the label never changes with the state.
Control it when something else reacts to the state:
const [bold, setBold] = React.useState(false);
<Toggle aria-label="Bold" pressed={bold} onPressedChange={setBold}>
<Glyph symbol="format_bold" />
</Toggle>Structure
| Property | Value |
|---|---|
| Height | 40px default · 32px sm · 44px lg, with a matching square min-width |
| Padding | 12px default · 8px sm · 16px lg horizontal |
| Typography | 14px / Inter 500 (text-sm font-medium); glyphs at 1.2em |
| Radius | --radius-md (6px) |
| Pressed | --accent fill with --accent-foreground ink (data-state=on) |
| Hover | --muted fill (default) · --accent (outline) |
| Outline | 1px --input border, --shadow-1 |
| Focus | 2px --ring |
| Disabled | 50% opacity, pointer events off |
Best practices
Do
- Give icon-only toggles an
aria-label— always. - Label the thing being toggled ("Bold", "Favourites"), and keep the label constant —
aria-pressedcarries the state. - Apply the effect immediately; a toggle is not a staged form input.
- Group related toggles in one toolbar row so they read as a set.
Don't
- Swap the label with the state ("Show" ↔ "Hide") — screen readers then hear a contradiction between label and pressed state.
- Use it inside a form for consent or options — that is Checkbox.
- Use it for navigation or a one-shot action — that is Button.
- Rely on colour alone to distinguish pressed in a dense toolbar — the
outlinevariant keeps a visible boundary.
Accessibility & keyboard
- Real
<button>semantics witharia-pressedreflecting the state — provided by Radix Toggle. - Icon-only toggles require
aria-label; the label must not describe the state. - Focus shows the 2px
--ringoutline — never remove it. - Keyboard: Tab to focus; Enter or Space toggles.
Props
Toggle also accepts every native <button> attribute, plus Radix's pressed,
defaultPressed and onPressedChange.
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | undefined | — | — |
pressed | boolean | undefined | — | The controlled state of the toggle. |
defaultPressed | boolean | undefined | false | The state of the toggle when initially rendered. Use `defaultPressed` if you do not need to control the state of the toggle. |
onPressedChange | ((pressed: boolean) => void) | undefined | — | The callback that fires when the state of the toggle changes. |
variant | "default" | "outline" | null | undefined | — | — |
size | "default" | "sm" | "lg" | null | undefined | — | — |
Button
Trigger an action or navigation. Seven variants cover the hierarchy from the one primary action per view down to inline links and the hero-only gradient CTA.
Input
A single-line text field for short, free-form responses — names, amounts, references. For longer text use Textarea; for a fixed set of choices use Select or Combobox.