Tabs
Index-card dividers. The active one comes forward and joins the page. Arrow keys move between them.
Client componentWCAG AASince v0.1
Live example
Cat in a teacup · Poster for the zine fair · Rosa’s comic, page 3
Birthday card for Lola · Band logo, final
Nothing flagged. Flag a sketch to come back to it here.
import { Tabs, TabList, Tab, TabPanel, Count } from "@plop-ui/react";
<Tabs defaultValue="active">
<TabList label="Your sketches">
<Tab value="active" badge={<Count label="3 active" size="sm">3</Count>}>Active</Tab>
<Tab value="resolved">Shipped</Tab>
</TabList>
<TabPanel value="active">…</TabPanel>
<TabPanel value="resolved">…</TabPanel>
</Tabs>Change every prop live in the playground.
Props
Tabs
| Prop | Type | Default | What it does |
|---|---|---|---|
| childrenrequired | ReactNode | none | A TabList of Tabs and a TabPanel for each. |
| className | string | none | Extra class on the wrapper. |
| defaultValue | string | none | Uncontrolled value of the tab selected first. |
| onValueChange | (value: string) => void | none | Called with the newly selected tab's value. |
| value | string | none | Controlled value of the selected tab. |
TabList
| Prop | Type | Default | What it does |
|---|---|---|---|
| childrenrequired | ReactNode | none | The Tabs. |
| labelrequired | string | none | Accessible name of the tab list, e.g. "Your sketches". |
| className | string | none | Extra class on the tab list. |
Tab
| Prop | Type | Default | What it does |
|---|---|---|---|
| childrenrequired | ReactNode | none | The tab's label, lettered in Sketchpop. |
| valuerequired | string | none | Identifies the tab; matches the value of its TabPanel. |
| badge | ReactNode | none | A count badge after the label (e.g. a <Count>). |
| disabled | boolean | false | Greys out the tab; it can't be picked and arrow keys skip it. |
Use it well
DoUse tabs to switch between views of the same thing.
Don'tUse tabs as steps in a process. People can't tell they have to visit each one.
Accessibility
- The WAI-ARIA tabs pattern: tablist, tabs with aria-selected and aria-controls, tabpanels.
- Roving tabindex; Arrow keys, Home and End move and select.