Tabs
Tabs lets people switch between several views of the same subject and shows which view is open.
<Tabs defaultValue="overview"> <TabsList> <TabsTab value="overview">Overview</TabsTab> <TabsTab value="activity">Activity</TabsTab> </TabsList> <TabsPanel value="overview">…</TabsPanel> <TabsPanel value="activity">…</TabsPanel></Tabs>Use Tabs to switch between views of one subject, such as the overview, activity and settings of a project. Selecting a tab shows its panel under the bar, and only one panel shows at a time. To choose a value that changes content in place, such as a list or grid view, use a SegmentedControl. For actions, use a Menu.
The open tab has full-strength text and a line under it in the accent colour, and the other tabs have muted text. The open tab doesn't get a fill or a heavier weight, because heavier text is wider and the bar would shift each time the tab changed.
Set size on TabsList, and every tab in the bar uses it. Tabs are always horizontal. To make each tab a link to a separate page, use render on TabsTab.
A screen reader announces a tab list, its tabs and their panels. Tab moves focus into the bar, the arrow keys move focus between tabs, and Enter or Space opens the focused tab. A disabled tab can still receive focus, but it can't be opened.
- Segmented Control when the options filter or change one view that stays on screen.
- Accordion when people may want several sections open, stacked on one page.
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.
Switching between views
It declares no props of its own. What it takes arrives from a shared type or from the primitive it is built on.
TabsList
The bar that holds the tabs, with the thin line along its bottom. Set size here, and the bar draws the line under the open tab for you
| Prop | Type | What it does |
|---|---|---|
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 tab bar, from 1 to 4. |
toneandemphasis— The only thing that sets one tab apart is whether it is open, and the bar already shows that. A colour or a louder style on a tab would compete with it.- TabsTrigger and TabsContent — In this library a trigger is something that opens a floating layer, such as a menu, and a tab opens nothing. The parts are called
TabsTabandTabsPanel, after the roles a screen reader announces. material— A tab bar has no background of its own, so there is nothing for the glass material to apply to.- An indicator part —
TabsListdraws and places the line under the open tab for you, so there is nothing to add and nothing to forget.