Skip to main content

Segmented control

Pick one of two to four modes.

24h 7d 30d
<mm-segmented-control name="range" label="Time range" value="7d">
<mm-segment value="24h">24h</mm-segment>
<mm-segment value="7d">7d</mm-segment>
<mm-segment value="30d">30d</mm-segment>
</mm-segmented-control>

Guidance​

Segmented controls pick one of two to four modes, such as a time range (“24h”, “7d”, “30d”) or a view (“Table”, “List”). The track is mm-surface with the control border; the selected segment is inverted ink. Labels are short and sentence case. It is a radio group: one tab stop, arrow keys move and select (flipped in right-to-left), and it submits its value with a form.

Keyboard follows the WAI-ARIA radio group pattern (https://www.w3.org/WAI/ARIA/apg/patterns/radio/).

Properties​

PropertyAttributeTypeDefaultDescription
valuevaluestring''The selected value.
labellabelstring''Group label, shown above the track unless hide-label is set.
hideLabelhide-labelbooleanfalseVisually hide the label (it is still announced). Common in toolbars.
helphelpstring''
errorerrorstring''
segmentsMmSegment[]
namenamestring''Name submitted with the form.
disableddisabledbooleanfalseDisables the control and excludes it from submission.
requiredrequiredbooleanfalseRequires a value before the form submits.
formHTMLFormElement | null
validityValidityState
validationMessagestring
willValidateboolean
isDisabledbooleanTrue when disabled directly or by a disabled ancestor fieldset.

Methods​

MethodDescription
formResetCallback()Restore the initial value when the owning form resets.

Events​

EventDetailDescription
changeEventNative-style change event.
mm-changeCustomEvent<{ value: string }>The selected segment changed by user action.
mm-inputCustomEvent<{ value: string }>Fired with mm-change.

Slots​

SlotDescription
Defaultmm-segment elements.

CSS parts​

PartDescription
trackThe radio group track.

Examples​

Every state of mm-segmented-control in Storybook, with keyboard and screen reader tests.