A linear set of two or more segments
SegmentedControl can be used with uncontrolled forms the same way as a native input element. Set the name attribute to include segmented control value in FormData object on form submission. To control the initial value in uncontrolled forms, use the defaultValue prop.
Example usage of uncontrolled SegmentedControl with FormData :
SegmentedControl supports two different data formats:
SegmentedControl supports generic value type. You can pass primitive values (numbers, strings, boolean, null) as the type argument. The generic type is used for value , defaultValue , onChange and data props.
Example with strings union:
To disable a SegmentedControl item, use the array of objects data format and set disabled: true on the item that you want to disable. To disable the entire component, use the disabled prop.
You can use any React node as a label:
By default, SegmentedControl uses theme.white with shadow in the light color scheme and var(--mantine-color-dark-6) background color for the indicator. Set the color prop to change the indicator background-color :
SegmentedControl supports autoContrast prop. If set to true , the label text color will automatically adjust to ensure optimal contrast against the indicator background color:
Change transition properties with:
500ms linear transition
Set the readOnly prop to prevent the value from being changed:
SegmentedControl supports the Styles API ; you can add styles to any inner element of the component with the classNames prop. Follow the Styles API documentation to learn more.
Component Styles API
Hover over selectors to highlight corresponding elements
SegmentedControl uses radio inputs under the hood, so it is accessible by default with no extra steps required if you have text in labels. The component supports the same keyboard events as a regular radio group.
If you do not have text in labels (for example, when you want to use SegmentedControl with icons only), use VisuallyHidden to make the component accessible: