Components · ActionsNot verified with Figma

Button group

A button group is a row of joined System buttons for choosing between two to four short options. The selected button has a black 12% fill.

Every example on this page is the real component, not a picture.

Playground

Joined System buttons that work as a toggle group. Click one to select it. This is the control the playgrounds on this site use.

Breakpoint
Options
Selected
Disabled option

Markup for this selection

HTML

Overview

A button group is a row of joined System buttons for choosing between two to four short options. The selected button has a black 12% fill.

It is a toggle group: your script sets aria-pressed on the chosen button. It is the control the playgrounds on this site use, and it fits a toolbar or a filter row. It is not the sliding pill (see Pill segment control).

This documentation has three pages. Examples & Guidelines (this page) shows when and how to use a button group. Specifications holds the values: tokens, sizes, measurements, states and requirements. Code shows how to add one to a page.


Usage

When to use

Use a button group to pick one of two to four short options in a toolbar, a filter row or a playground. Use it to:

  • Switch between a few values of one setting, such as a size or a view
  • Filter a list in a compact toolbar, with a visible label beside the group

When not to use

For more than four options

The group never wraps onto a second row, and it is never made smaller to fit. With more options, or when the group does not fit its container, show a select with the same options instead.

Do use two to four short options.
Do not use it for more than four options. Use a select instead.

Keep labels short

The group shows all its options on one row. Short labels keep it narrow; long labels make it wider than its container.

Do keep the labels short.
Do not use long labels: the group grows wider than its container.

Quick reference

The user…Use
picks one of 2–4 short options on a toolbar or in a playgroundButton group
switches the main view of a surface with a sliding pillPill segment control
picks one of many optionsSelect
picks one and submitsRadio
goes to another pageTabs or a link

Do

  • Keep to 2–4 options with short labels.
  • Label the group with aria-label or a visible label.
  • Set aria-pressed on the selected button.
  • Link button-group.css.

Don’t

  • Wrap the group onto two rows.
  • Use it for page navigation.
  • Allow more than one selected unless you mean a multi-select toggle.
  • Copy its rules into the page.

Anatomy

Button group

  1. Group. A role="group" row of buttons. It is inline-flex and never wider than its parent.
  2. Selected button. aria-pressed="true": a black 12% fill and the same frame.
  3. Button. A System button with an uppercase label. Hover darkens the frame and adds the fill.
  4. Shared frame. A 1px frame is drawn inside each button and shared between neighbours with margin-left: -1px.

Variants

Two to four short options on one row. The group never wraps. With more options, use a select.

Option counts

With a label, as in a toolbar

View

Sizes

The button group has one size: Small System buttons, 32px high on mobile and 40px from 769px. The tablet range (640 to 768px) uses the mobile size. Measurements are under Sizes in Specifications.

Breakpoint

Layout & Appearance

Width

The group is as wide as its buttons and never wider than its parent. Buttons share their 1px frame. When the group does not fit, for example in a narrow controls column, show a select with the same options and keep the two in sync.

Alignment

A group sits at the start of its row (align-self: flex-start). In a toolbar put the visible label before it.

Appearance

A light frame, an uppercase label and a black 12% fill for the selected button. Token names and values are under Design Tokens in Specifications.


Behavior

Selection

One button is selected at a time. Your script sets aria-pressed; the CSS does not toggle it.

Hover and focus

Hover darkens the frame to border-hover and, when the button is not selected, adds the fill. The focus ring is 2px with a 2px gap and shows on keyboard use only (body.keyboard-nav). All states are listed under States in Specifications.

Disabled

A disabled button is not focusable. Its label and frame use the disabled tokens.

Motion

The frame and the fill change over 100ms. Values are under Motion in Specifications.


Accessibility

All requirements are listed under Accessibility Requirements in Specifications.

Keyboard support

Tab moves between the buttons. Enter or Space chooses the focused one. The focus ring shows on keyboard use only.

Screen reader support

The group is a role="group" with an aria-label or aria-labelledby. Each button is a real <button type="button"> with aria-pressed, so the chosen one is announced as pressed.



References