Tabs
A set of views of the same content, one visible at a time, switched with a row of tabs, built on Radix Tabs.
12 documentos anexados ao processo, entre eles a petição inicial e a contestação.
Select a tab, or focus the row and use the arrow keys.
When to use
- To split one page into 2 to 6 related sections the user compares or switches between: documents, tasks and history of a process.
- When the sections share the same page header and context, and only one needs to be on screen at a time.
- When the user should not lose their place on the page when switching.
When not to use
- Moving between pages or steps of a flow. Use links in the Sidebar, or a Breadcrumb for hierarchy.
- Choosing a value in a form. Use a Radio group, or a Select.
- Filtering a list. Use Radio filter or filter controls.
- Content the user must read in sequence. Use sections on the same page.
Anatomy
| Part | Role |
|---|---|
Tabs |
Holds the active tab. Use defaultValue or value and onValueChange. |
TabsList |
The row of triggers. Name it with aria-label. |
TabsTrigger |
One tab. Its value links it to the content. |
TabsContent |
The panel for one value. Only the active panel is rendered in the page. |
Examples
Default
The active tab has a brand-colored underline and primary text.
12 documentos anexados ao processo, entre eles a petição inicial e a contestação.
Disabled tab
Use disabled for a section that is not available yet and say why in the other panels. A disabled tab is skipped by the arrow keys.
Contestação em elaboração. O protocolo fica disponível após a revisão.
Manual activation
With activationMode="manual" the arrow keys only move focus. Enter or Space opens the tab. Use it when each panel is expensive to load.
Autor e réu identificados na petição inicial.
States
| State | Look |
|---|---|
| Default | Secondary text, transparent underline. |
| Hover | Surface background on the top corners. |
| Active | Primary text, brand underline. |
| Focus | Focus ring with a 2px offset, on keyboard focus only. |
| Disabled | Not clickable, text at half opacity. |
Content
- Use one or two words, as nouns: “Documentos”, “Tarefas”, “Histórico”.
- Keep labels the same length where you can, so the row reads evenly.
- Do not repeat the same word in every tab (“Ver documentos”, “Ver tarefas”).
- Name the row with a translated
aria-labelonTabsList, such as “Seções do processo”.
Do and don’t
Accessibility
- Built on Radix Tabs.
TabsListhasrole="tablist", each triggerrole="tab"witharia-selected, and each panelrole="tabpanel"linked to its trigger witharia-controlsandaria-labelledby. Tabmoves focus into the list on the active trigger, and out of it to the active panel. Only the active tab is in the tab order (roving tabindex).LeftandRightarrow keys move between triggers and loop at the ends.HomeandEndgo to the first and last. Withorientation="vertical"the keys areUpandDown.- In
automaticmode the focused tab activates at once. Inmanualmode,EnterorSpaceactivates it. - Disabled triggers are skipped by the arrow keys.
- Each trigger is about 33px tall, above the 24px minimum.
- Give the tab list an accessible name (
aria-label): the component does not.
Code
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@repo/ui/tabs";
<Tabs defaultValue="documents">
<TabsList aria-label="Seções do processo">
<TabsTrigger value="documents">Documentos</TabsTrigger>
<TabsTrigger value="tasks">Tarefas</TabsTrigger>
</TabsList>
<TabsContent value="documents">…</TabsContent>
<TabsContent value="tasks">…</TabsContent>
</Tabs>;
Props
Tabs| Prop | Type | Default | Description |
|---|---|---|---|
activationMode | "automatic" | "manual" | automatic | `automatic` activates a tab when it receives focus; `manual` waits for `Enter` or `Space` |
defaultValue | string | — | Value of the tab that is active on first render |
onValueChange | (value: string) => void | — | Called when the active tab changes |
orientation | "horizontal" | "vertical" | horizontal | Direction of the arrow keys that move between tabs |
value | string | — | Controlled value of the active tab |
TabsTrigger| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Required. Identifies the tab and links it to its TabsContent. |
disabled | boolean | false | Prevents the tab from being selected. |
TabsContent| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Required. Matches the value of its trigger. Shown only while that tab is active. |
forceMount | true | — | Keeps the panel in the page while it is inactive. |
TabsList| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | — | Accessible name of the tab list. Pass translated copy. |
loop | boolean | true | Whether the arrow keys wrap around at the ends. |
Known issues
| Issue | Effect |
|---|---|
TabsContent sets focus-visible:ring-0, and Radix makes the panel focusable. |
Pressing Tab from the list lands on the panel with no visible focus indicator. |
The pressed state is active:bg-[rgba(0,0,0,0.1)], a hardcoded translucent color. |
A black overlay at 10% opacity: it does not follow the theme tokens and has little effect on dark backgrounds. |
Disabled triggers use disabled:opacity-50. |
A translucent fill: the repository avoids transparency, and the label contrast drops below AA. |
TabsList sets its border with an arbitrary value, border-[hsl(var(--stroke-tertiary))]. |
It bypasses the named border token classes. |
TabsTrigger sets size and weight with raw classes (text-sm font-medium), not Typography. |
The text does not follow the type scale tokens. |