Skip to main content
  1. Docs
  2. Components
  3. Actions

Toggle group

A row of toggles: one view among a few, or a set of tools that are each on or off.

Import
@qeetrix/react
Status
StableSince 0.0.2
Renders
<div role="group">Server-rendered
Tested
WCAG 2.2 AAaxe on every pull request

01

When to use

Use it for
  • Switching between views of the same thing: grid or list, 7, 30 or 90 days.
  • A set of tools: bold, italic, underline.
  • A choice that applies at once, with two to five options.
Not for
  • Moving between panels of contentTabs
  • A choice in a form that's submittedRadio
  • More than five optionsSelect
  • One tool on its ownToggle

02

Anatomy

  1. 1toggle-group<div role="group">The root: one Tab stop; arrow keys move inside.
  2. 2toggle<button>Each choice, with aria-pressed.

03

Do and don't

A few, all in view
DoTwo to five short choices.
Don'tSeven to scan: that's a Select's job.
A form answer is a radio
DoSubmitted with the form: a radio group, labelled.
Don'tA segmented control in the middle of a form.

04

Sizes

Each height follows the region's density.

SizeHeight: compact / default / comfortable
sm24 / 28 / 32
md28 / 32 / 36
lg32 / 40 / 44

05

Content

  • Short labels, one or two words: "7 days", "Grid".
  • Name the group: aria-label says what's being chosen, "Members view".
  • Icon-only toggles: each needs its own aria-label.
Next — Toggle groupAPI