- Docs
- Components
- Navigation
Tabs
Views of the same thing, one at a time. One Tab stop; the arrow keys move between them.
- Import
- @qeetrix/react
- Status
- StableSince 0.0.2
- Renders
<div role="tablist">Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Playground
Every prop, live, and the code it takes.
import { Tab, Tabs, TabsList, TabsPanel } from "@qeetrix/react";
<Tabs defaultValue="users">
<TabsList aria-label="Payroll portal">
<Tab value="overview">Overview</Tab>
<Tab value="users" badge={642}>Users</Tab>
<Tab value="sign-in">Sign-in</Tab>
<Tab value="credentials">Credentials</Tab>
</TabsList>
<TabsPanel value="users">…</TabsPanel>
</Tabs>02
Views of one thing
One Tab stop: the arrow keys move and select, Home and End jump, and Tab goes on to the panel.
<Tabs defaultValue="profile">
<TabsList aria-label="Priya Sharma">
<Tab value="profile">Profile</Tab>
<Tab value="security">Security</Tab>
<Tab value="sessions">Sessions</Tab>
</TabsList>
<TabsPanel value="profile">…</TabsPanel>
<TabsPanel value="security">…</TabsPanel>
<TabsPanel value="sessions">…</TabsPanel>
</Tabs>03
Contained
variant="contained": a segmented strip, for a few views of one card or panel.
<TabsList variant="contained" aria-label="Users">
<Tab value="all">All users</Tab>
<Tab value="invitations">Invitations</Tab>
<Tab value="blocked">Blocked</Tab>
</TabsList>04
Icons and counts
icon, filled while selected (filledWhenSelected={false} keeps the outline); badge, a number formatted for the locale, or your own Badge.
<Tab value="users" icon={UsersIcon} badge={642}>Users</Tab>
<Tab value="credentials" icon={KeyRoundIcon} badge={<Badge tone="danger">1</Badge>}>
Credentials
</Tab>05
Vertical
orientation="vertical": the line and the bar on the start edge; Up and Down move.
<Tabs defaultValue="general" orientation="vertical">
<TabsList aria-label="Organisation settings">…</TabsList>
<TabsPanel value="general">…</TabsPanel>
</Tabs>06
More than fit
The list scrolls sideways; it never wraps to a second row.
<TabsList aria-label="Payroll portal">
<Tab value="overview">Overview</Tab>
…
<Tab value="logs">Logs</Tab>
</TabsList>07
Slow panels
activateOnFocus={false}: the arrows only move focus, and Enter or Space selects. For panels that load slowly.
<TabsList aria-label="Priya Sharma" activateOnFocus={false}>…</TabsList>08
Controlled
value and onValueChange: the view in your state, or in the address.
const [tab, setTab] = useState("sessions");
<Tabs value={tab} onValueChange={setTab}>…</Tabs>