SegmentedControl

SegmentedControl is used to pick one choice from a linear set of closely related choices, and immediately apply that selection.

Page navigation navigation

Anatomy

A diagram of a SegmentedControl with three buttons. The labeled parts of the SegmentedControl are: the selected third button, the icon in the second button, and the text label in the second button.Edit in Figma

Usage

For implicitly saved settings

Use SegmentedControls to pick and immediately apply an option, similar to radio inputs but without needing form submission.

Edit in Figma

For more information about explicit and automatic save patterns, see the saving pattern guidleines.

To toggle content visibility

The current implementations of our SegmentedControl do not support rendering segments as links (<a> tags). Continue to avoid using SegmentedControls that change the URL until we have a solution for rendering segments as links.

SegmentedControls may also be used to change how content in a view is rendered. The following use cases are an acceptable use for a SegmentedControl:

  • Sort control: Sort items in a list.
  • Filter control: Show/hide list items, and there should be a segment that shows the full list.
  • Content formatting picker: Changes the formatting of the same content.
A screenshot of a GitHub discussions list with the segmented SegmentedControl for sorting highlighted. The sort options are 'Oldest', 'Newest', and 'Top'.Edit in Figma
As a sort control
A screenshot of the GitHub organization insights page with the SegmentedControl for filtering highlighted. The options are 'All results' and 'Open security advisories'. Edit in Figma
As a filter control
A screenshot of the GitHub billing dashboard with a chart showing costs. The SegmentedControl to switch between the chart type is highlighted. The options are 'Line', 'Area', and 'Bar'Edit in Figma
As a content formatting picker

If selecting a segment changes the URL, the segments should be rendered as <a> tags.

See the decision tree for choosing a pattern for tabbed interfaces for more detailed guidance and alternative patterns.

Content

Segments

A SegmentedControl should have 2–5 choices with text labels, or up to 6 icon-only segments. If more are needed, consider another choice selection component such as RadioGroup or ActionMenu.

Do
Edit in Figma
Use a SegmentedControl for picking from 5 (6 for icon-only segments) or fewer options.
Don’t
Edit in Figma
Don't use a SegmentedControl for more than 5 options.
Do
Edit in Figma
Use a SegmentedControl for selecting from a list of static values. You may use an auxiliary dropdown adjacent to the SegmentedControl.
Don’t
Edit in Figma
Don't use a SegmentedControl with a choice that is a dropdown.

Segment icons

Icons add visual cues. Be consistent (all icons, all text, or icons with text) and don’t change icons to indicate state.

Do
Edit in Figma
Use icons as a visual cue to communicate what the choice does.
Don’t
Edit in Figma
Don't change or add icons to indicate whether the choice is selected.
Do
Edit in Figma
Keep the visual cues in each segment consistent.
Don’t
Edit in Figma
Don't mix visual cues between segments.

Icon-only segments

Icons without text labels are fine if their meaning is obvious. Include a tooltip for clarity.

Do
Edit in Figma
Use icons without a visible label when the icon's meaning is obvious.
Don’t
Edit in Figma
Don't use obscure icons without a visible label.

Segment label text

Label segments with nouns or short phrases; avoid multiline labels.

Do
Edit in Figma
Phrase choice labels as nouns or noun phrases with as few characters as possible.
Don’t
Edit in Figma
Don't phrase choice labels as an action or with unnecessarily long strings of text.

Contextual information

Label

SegmentedControls must have a text label, even if the label is only accessible to screen readers.

A visible label is the most direct way to identify what the control is used for, but the location and surrounding elements of the control often give enough context to visually hide the label.

Caption

An optional caption may be used to provide additional context to help users make a selection or explain what effect the selection will have. Caption text should be as short as possible.

See the layout section for ways to compose a SegmentedControl with a label.

Interaction

Selections are mutually exclusive and apply instantly, without needing a "Save" button. Once a selection has been made, it can only be deselected by making a new selection.

Layout

Composing the control with a label and caption

Single-column

A single-column layout is the same way form controls (for example, TextInputs) are layed out. The single-column layout is useful for preserving horizontal space.

Edit in Figma

Two-column

Aligns controls with adjacent elements and conserves vertical space while grouping related controls in a way that's easy to scan.

Responsive design

For narrow spaces, use icons only or replace the control with an ActionMenu.

Convert to an ActionMenu

Swapping out the SegmentedControl for an ActionMenu is especially helpful when:

  • The icons cannot be understood without visible text labels
  • The control is still too wide when text labels are hidden
Edit in Figma

Only show icons

If your SegmentedControl uses icons that can be understood without a visible text label, then you can hide the text labels and rely only on icons.

Edit in Figma
Do
Edit in Figma
Replace the SegmentedControl with an ActionMenu or use icons that are easily understood without text labels.
Don’t
Edit in Figma
Wrap the buttons to multiple lines, use an overflow button, or remove buttons