Search
HomeGet startedDevelopStylesComponents
Components overviewApp barsBadgesButtonsButton groupsButtonsExtended FABsFAB menuFABsIcon buttonsSegmented buttonsSplit buttonsCardsCarouselCheckboxChipsDate & time pickersDate pickersTime pickersDialogsDividerListsLoading & progressLoading indicatorProgress indicatorsMenusNavigationNavigation barNavigation drawerNavigation railRadio buttonSearchSelectSheetsBottom sheetsSide sheetsSlidersSnackbarSwitchTabsText fieldsToolbarsTooltips

Segmented buttons

Two to five options side by side: choose one, or several.

Your downloads

Songs Albums Podcasts
FactoryWeb ComponentsReactVueSvelteSolid

Accessibility

Keyboard

Tab reaches every segment. Try a single choice, and a price filter where several can stay selected.

Restaurants Bars $ $$
On Keys What it does
Segments Tab Shift+Tab Goes to the next or the previous segment, including across segmented buttons.
Segments Left Right Up Down Leaves the focus on the same segment: the arrow keys do not move between segments, as M3 asks.
Single-select segment Enter Space Selects it and clears the other choice.
Multi-select segment Enter Space Selects it, or clears it when it is selected; the others keep their state.

Focus

Focus follows the segments’ order in both reading directions. Tab does not reach the segmented button itself.

Restaurants Bars
Left to right
Restaurants Bars
Right to left

Screen readers

What the browser tells assistive technology of the example above. How a screen reader says it is its own choice.

Part Role Name State
Segmented button group ariaLabel
Segment button Its text, or ariaLabel Pressed or not pressed

Touch targets

Each segment can be pressed over its own box only: 40px tall at the default density, 36 and 32px at comfortable and compact, under the 48px M3 asks for.

Restaurants Bars
Default
Restaurants Bars
Comfortable
Restaurants Bars
Compact

Display

  • A selected segment shows a check mark as well as its color, so color is not the only sign of selection.

Best practices

Name the segmented button for the choice it holds, and keep each segment’s text short.

Vanilla
import { createSegmentedButton } from 'material/components/segmented-button';

const segmentedButton = createSegmentedButton({
  ariaLabel: 'Places',
  segments: [
    { text: 'Restaurants', value: 'restaurants', selected: true },
    { text: 'Bars', value: 'bars' },
  ],
});
document.body.append(segmentedButton.element);
Web Components
<m-segmented-button value="restaurants" aria-label="Places">
  <m-segment value="restaurants">Restaurants</m-segment>
  <m-segment value="bars">Bars</m-segment>
</m-segmented-button>
React
import { useState } from 'react';
import { SegmentedButton, Segment } from 'material/react/segmented-button';

export function Example() {
  const [value, setValue] = useState("restaurants");
  return (
    <SegmentedButton value={value} onChange={(event) => setValue(event.detail.value)} ariaLabel="Places">
      <Segment value="restaurants">Restaurants</Segment>
      <Segment value="bars">Bars</Segment>
    </SegmentedButton>
  );
}
Vue
<script setup lang="ts">
import { ref } from 'vue';
import { MSegmentedButton, MSegment } from 'material/vue/segmented-button';

const value = ref("restaurants");
</script>

<template>
  <MSegmentedButton v-model="value" aria-label="Places">
    <MSegment value="restaurants">Restaurants</MSegment>
    <MSegment value="bars">Bars</MSegment>
  </MSegmentedButton>
</template>
Svelte
<script lang="ts">
  import SegmentedButton from 'material/svelte/segmented-button';

  let value = $state("restaurants");
</script>

<SegmentedButton bind:value ariaLabel="Places">
  <m-segment value="restaurants">Restaurants</m-segment>
  <m-segment value="bars">Bars</m-segment>
</SegmentedButton>
Solid
import { createSignal } from 'solid-js';
import { SegmentedButton, Segment } from 'material/solid/segmented-button';

export function Example() {
  const [value, setValue] = createSignal("restaurants");
  return (
    <SegmentedButton value={value()} onChange={(event) => setValue(event.detail.value)} ariaLabel="Places">
      <Segment value="restaurants">Restaurants</Segment>
      <Segment value="bars">Bars</Segment>
    </SegmentedButton>
  );
}
  • Give the segmented button ariaLabel: its group is otherwise named Segmented button.
  • Give an icon-only segment ariaLabel in the factory; the web component cannot name one yet.
  • For a new design, prefer the connected button group, which M3 Expressive recommends in its place.

Known gaps