SegmentedControl
A linear set of two or more segments
Import
Source
Docs
Package
Usage
Controlled
Data prop
SegmentedControl
support two different data formats:
- An array of strings – used when
value
andlabel
are the same - An array of objects – used when
value
andlabel
are different
Disabled
To disable SegmentedControl
item, use array of objects data
format and set disabled: true
on the item that you want to disable. To disable the entire component, use disabled
prop.
Disabled control
Disabled option
React node as label
You can use any React node as label:
Color
By default, SegmentedControl
uses theme.white
with shadow in light color scheme and var(--mantine-color-dark-6)
background color for indicator.
Set color
prop to change indicator background-color
:
Transitions
Change transition properties with:
transitionDuration
– all transitions duration in ms,200
by defaulttransitionTimingFunction
– all transitions timing function,ease
by default
No transitions
500ms linear transition
readOnly
Set readOnly
prop to prevent value from being changed:
Styles API
SegmentedControl
supports Styles API, you can add styles to any inner element of the component withclassNames
prop. Follow Styles API documentation to learn more.
Component Styles API
Hover over selectors to highlight corresponding elements
Accessibility and usability
SegmentedControl
uses radio inputs under the hood, it is accessible by default with no extra steps required if you have text in labels.
Component support the same keyboard events as a regular radio group.
In case you do not have text in labels (for example, when you want to use SegmentedControl
with icons only),
use VisuallyHidden to make component accessible: