Skip to content

SegmentedControl

Draft
Use a segmented control to let users select an option from a short list and immediately apply the selection
Not implemented yet

Examples

Simple

With icons and labels

With icons only

With labels hidden on smaller viewports

Convert to a dropdown on smaller viewports

Fill width of parent

In a loading state

With a label and caption on the left

With a label above and caption below

With something besides the first option selected

With a selection change handler

Props

SegmentedControl

NameTypeDefaultDescription
aria-label
string
aria-labelledby
string
aria-describedby
string
fullWidth
boolean
Whether the control fills the width of its parent
loading
boolean
Whether the selected segment is being calculated
onChange Required
(selectedIndex?: number) => void
The handler that gets called when a segment is selected
variant
{ narrow?: 'hideLabels' | 'dropdown', regular?: 'hideLabels' | 'dropdown', wide?: 'hideLabels' | 'dropdown' }
Configure alternative ways to render the control when it gets rendered in tight spaces
sx
SystemStyleObject
Style overrides to apply to the component. See also overriding styles.
ref
React.RefObject<HTMLDivElement>
A ref to the element rendered by this component.

SegmentedControl.Button

NameTypeDefaultDescription
leadingIcon
Component
The leading icon comes before item label
selected
boolean
Whether the segment is selected
sx
SystemStyleObject
Style overrides to apply to the component. See also overriding styles.
ref
React.RefObject<HTMLButtonElement>
A ref to the element rendered by this component.

SegmentedControl.IconButton

NameTypeDefaultDescription
aria-label Required
string
icon Required
Component
The icon that represents the segmented control item
selected
boolean
Whether the segment is selected
sx
SystemStyleObject
Style overrides to apply to the component. See also overriding styles.
ref
React.RefObject<HTMLButtonElement>
A ref to the element rendered by this component.

Status

Alpha

  • Component props are documented on primer.style/react.
  • Component does not have any unnecessary third-party dependencies.
  • Component can adapt to different themes.
  • Component can adapt to different screen sizes.
  • Component has 100% test coverage.

Beta

  • Component is used in a production application.
  • Common usage examples are documented on primer.style/react.
  • Common usage examples are documented in storybook stories.
  • Component has been reviewed by a systems designer and any resulting issues have been addressed.
  • Component has been manually reviewed by the accessibility team and any resulting issues have been addressed.

Stable

  • Component API has been stable with no breaking changes for at least one month.
  • Feedback on API usability has been sought from developers using the component and any resulting issues have been addressed.
  • Component has corresponding design guidelines documented in the interface guidelines.
  • Component has corresponding Figma component in the Primer Web library.