SegmentedControl
Usage
SegmentedControl is usually used as an alternative to:
- Tabs to switch views
- RadioGroup to capture user feedback limited to certain options
Controlled
Data prop
SegmentedControl support two different data formats:
- An array of strings – use when you do not need to customize item component or display
label
different thanvalue
- An array of objects with required
value
andlabel
properties and any other additional properties
React node as label
You can use any React node as label in data
prop:
Full width
By default SegmentedControl is inline and will take only the amount of space which is required to render elements.
Set fullWidth
prop to make it block and take 100% width of its container.
Sizes
Component supports 5 sizes: xs, sm, md, lg, xl. Size controls font-size and padding properties.
SegmentedControl sizes from xs to xl:
Radius
xs, sm, md, lg, xl radius values are defined in theme.radius. Alternatively, you can use a number to set radius in px:
Default theme radius values from xs to xl with lg size:
Color
By default segmented control uses theme.white
with shadow in light color scheme and theme.colors.dark[6]
background color for active element.
You can choose any color defined in theme.colors in case you need colored variant:
Transitions
Change transition properties with:
- transitionDuration – all transitions duration in ms (ignored if user prefers to reduce motion)
- transitionTimingFunction – defaults to
theme.transitionTimingFunction
Accessibility and usability
SegmentedControl uses radio inputs under the hood, it is accessible by default with no extra steps required. Component support the same keyboard events as regular radio group.