Components / Base / Segmented control

B4 · Base

Segmented control

One choice out of a short set, drawn as a joined row of pills.

When to use

  • There are two to five peer options.
  • The choice takes effect immediately.

When not to use

  • Each option opens a different panel with its own heading. Use tabs.
  • The options do not exclude each other.

Usage

<div class="c-seg" role="radiogroup" aria-label="Range">
  <button type="button" role="radio" aria-checked="true">Day</button>
  <button type="button" role="radio" aria-checked="false">Week</button>
</div>

Variants

The preview shows the form used in the gallery.

Props

NameTypeDefaultDescription
roleradiogroup / radio—The row and each option.
aria-checkedtrue or falsefalseThe selected option.

Keyboard

KeyAction
ArrowLeft / ArrowRightMoves the selection.
TabEnters and leaves the group.

Accessibility

Motion

Pattern origin

Base control for a single immediate choice.

Related

Pill tabsFilter chipsLine chart