Segmented Control
SegmentedControl shows a few options side by side and lets someone pick one of them.
<SegmentedControl defaultValue="grid" aria-label="View"> <SegmentedItem value="list">List</SegmentedItem> <SegmentedItem value="grid">Grid</SegmentedItem></SegmentedControl>Use a SegmentedControl for two to five short options that change a setting in place, such as a list or grid view. When the choice switches the content below it, use Tabs. When people can pick more than one option, use a ToggleGroup of Toggles, and when there are too many options to show at once, use a Select.
The chosen option sits on a raised tile, and the control is as tall as a Button of the same size, so it lines up in a toolbar. Every segment has the same weight, and you set the size once on the control rather than on each segment.
Set backdrop when content passes behind the control, such as an image, and it uses the theme's glass material. A <Box backdrop> around a whole toolbar does the same for every control inside it.
A screen reader announces the control as a radio group, because picking one of several options is what a radio group does. The arrow keys move the choice from one segment to the next. Give the control an aria-label that names the setting.
- Tabs when each option is a different view, with its own content.
import { Flex, SegmentedControl, SegmentedItem, Stack, Tabs, TabsList, TabsTab,} from "@kushagradhawan/kookie-ui-react";export default function TabsOrSegmented() { return ( <Stack gap="7"> <Flex justify="center"> <Tabs defaultValue="usage"> <TabsList> <TabsTab value="usage">Usage</TabsTab> <TabsTab value="invoices">Invoices</TabsTab> <TabsTab value="limits">Limits</TabsTab> </TabsList> </Tabs> </Flex> <Flex justify="center"> <SegmentedControl defaultValue="month" aria-label="Date range" > <SegmentedItem value="day">Day</SegmentedItem> <SegmentedItem value="week">Week</SegmentedItem> <SegmentedItem value="month">Month</SegmentedItem> </SegmentedControl> </Flex> </Stack> );}Topics
Every symbol this component exports, grouped by the job it does. Each one carries the props it declares; each one has an anchor of its own.
Picking one of a few
SegmentedControl
SegmentedControl shows a few options side by side and lets someone pick one of them.
| Prop | Type | What it does |
|---|---|---|
backdrop? | boolean | Set backdrop when the control sits over other content, such as an image. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
size? | "1" | "2" | "3" | "4" | The size step of the control, from 1 to 4. |
toneandemphasis— The options in a SegmentedControl are equal choices, so none of them should look louder than the others. The control always uses the same neutral colours.- Selecting more than one option — A SegmentedControl holds exactly one answer. When people can turn several options on at once, use a
ToggleGroupofToggles. nativeButtonandrender— A segment is always the same element. SettingnativeButtonwould stop Space from selecting it, and changing the element withrendergives you nothing a segment needs.readOnly— HTML has no read-only version of a selection control, so there is no familiar look to copy. Usedisabledwhen the choice can't be changed.