Tabs
import { Tabs } from "@study/ui"
Result
Loading...
Live Editor
function Example() { const [tab, setTab] = useState("overview"); return ( <Tabs label="Areas of the course" active={tab} onSelect={setTab} items={[ { id: "overview", label: "Overview" }, { id: "documents", label: "Documents" }, { id: "notes", label: "Notes" }, { id: "lectures", label: "Lectures" }, { id: "flashcards", label: "Flashcards", count: 11 }, ]} trailing={<IconButton icon="more" label="More areas" />} /> ); }
In the app the tabs are links, so that every area has its own address:
<Tabs label="Bereiche des Fachs" active={tab} linkAs={Link}
items={MAIN_TABS.map((t) => ({ id: t, label: de.tabs[t], href: `/faecher/${id}/${t}` }))} />
Variants and states
Light
Dark
When to use
- For areas of one thing (a course, the settings) – not for the main navigation.
- At most six visible; rare ones behind an
IconButton⋯ astrailing. - For choosing a value: SegmentedControl.
Props
| Prop | Type | Default | Meaning |
|---|---|---|---|
active * | string | – | The id of the current tab. |
items * | TabItem[] | – | |
label * | string | – | What the tabs switch between, e.g. "Areas of the course". |
className | string | – | |
linkAs | ElementType | – | The link element for `href` tabs, e.g. react-router's `Link` (it gets `to`). |
onSelect | ((id: string) => void) | – | |
size | "sm" | "md" | md | |
trailing | ReactNode | – | At the end of the bar, e.g. an `IconButton` "More areas". |
Accessibility
- A
navwith a name; the active tab isaria-current. - Links stay links (Ctrl-click, back button); buttons stay buttons.