Components · FormNot verified with Figma

Pill segment control

A pill segment control switches between two to four related views or filters in the same surface. A pill slides to the active segment.

Every example on this page is the real component, not a picture. Figma: Pill segment control.

Playground

Click a segment and the pill slides to it. Large is the page-level switcher; XSmall is for tight toolbars. Below 640px the control fills its parent; from 640px it shrinks to its content.

Size
Segments
Pill
Track

The animation is set in Motion.

Markup for this selection

HTML

Overview

A pill segment control switches between two to four related views or filters in the same surface. A pill slides to the active segment.

It has four sizes (Large, Medium, Small, XSmall), a black or a white pill, and a track that darkens on hover. It never replaces Tabs (navigation between pages) or Radio buttons (a choice that is submitted).

This documentation has three pages. Examples & Guidelines (this page) shows when and how to use a pill segment control. 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 pill segment control to switch between two related views or filters in the same surface, for example User roles / Company plan or All features / Key features. Use it to:

  • Switch the view of one surface, at page level (Large) or in a drawer (Medium)
  • Filter a list or a table in a compact toolbar (Small, XSmall)

When not to use

For more than four options

A segmented control is for two to four short, related options on one row. It never wraps onto a second row. For more options use eco-select, or eco-radio if all must stay visible.

Do use two to four short options.
Do not use it for more than four options.

For navigation or a submitted choice

To move between pages or sections use Tabs. For a choice that is submitted use eco-radio. For a setting that turns on or off use Switch.

Keep labels short

The control shows all its segments 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 control grows wider than its container.

Quick reference

The user…Use
switches between 2–4 views or filters of the same contentPill segment control
switches between a few options in a toolbar, joined and framedButton group
moves between pages or sectionsTabs
makes a choice that is submittedeco-radio
turns one setting on or offSwitch

Do

  • Use for two to four related views in one surface.
  • Choose the size by where it sits.
  • Listen for segment-change to swap the content.
  • Keep labels short.

Don’t

  • Replace tabs or radio buttons with it.
  • Add a second focus ring.
  • Let it wrap onto two rows.
  • Build your own thumb positioning: use the shared script.

Anatomy

Pill segment control

  1. Track. The rounded frame. Its radius is half its height. It darkens on hover.
  2. Pill. The black (or white) shape behind the active segment. It is its own element and slides between the segments.
  3. Active segment. A button with aria-pressed="true". White text on the black pill.
  4. Inactive segment. A transparent button with black text. It is underlined on hover.

Variants

The pill is black by default; use the white pill when the control already sits on a dark or grey surface. Sizes are under Sizes below.

White pill

For a control inside another, larger control, on a grey track. The active text stays black.


Sizes

Four sizes, two to four segments. Large is the page-level view switcher, Medium a view switcher in a drawer, Small secondary filters and XSmall compact filters in a table toolbar. Measurements are under Sizes in Specifications.


Layout & Appearance

Width

Below 640px the control is fluid: it fills its parent and the segments share the space evenly. From 640px it shrinks to its content. Height, padding and text do not change until 769px, so 640–768px still has the mobile size.

Appearance

A grey track with a black pill and uppercase labels. The pill has a small shadow. Token names and values are under Design Tokens in Specifications.


Behavior

Switching

A click on a segment moves the pill to it, sets aria-pressed and fires a bubbling segment-change event with detail.button. Your page listens for the event and swaps the content.

Hover and focus

Hover darkens the track to border-tertiary and underlines the inactive segment. Focus has no style of its own: the buttons use the global keyboard focus ring. All states are listed under States in Specifications.

Motion

The pill slides with duration-medium-2 and ease-standard. Try other values under Motion above.


Accessibility

All requirements are listed under Accessibility Requirements in Specifications.

Keyboard support

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

Screen reader support

The control is a role="group" with an aria-label. Each segment is a button with aria-pressed, so the active one is announced as pressed.