On this page

InstallationUsageAnatomyVariantsSizesWidthIconsCountsA badgeAn info iconA tab to something dangerousVerticalMotionIn the dashboardAccessibilityAPI ReferenceTabsTabsListTabsTriggerTabsContentRulesWritten downOpen questionsWhat others adviseWhat others expose

Tabs

Switches between sections or views: one shows at a time.

1<Tabs defaultValue="overview">2  <TabsList aria-label="Agent">3    <TabsTrigger value="overview">Overview</TabsTrigger>4    <TabsTrigger value="runs" count={4}>Runs</TabsTrigger>5    <TabsTrigger value="security">Security</TabsTrigger>6    <TabsTrigger value="settings">Settings</TabsTrigger>7  </TabsList>8</Tabs>

Installation

import { Tabs, TabsContent, TabsList, TabsTrigger } from "@catalog-developer/components";

Usage

A TabsContent per tab, with the tab's value. Only the selected panel is in the page; keepMounted keeps the others, with their state. A list can also stand without panels and drive a value you hold.

What the agent is.
1<Tabs defaultValue="overview">2  <TabsList aria-label="Agent">3    <TabsTrigger value="overview">Overview</TabsTrigger>4    <TabsTrigger value="runs">Runs</TabsTrigger>5  </TabsList>6  <TabsContent value="overview">What the agent is.</TabsContent>7  <TabsContent value="runs">What it did.</TabsContent>8</Tabs>

Anatomy

12345
  1. 1 — List. The row. A segment's list is a track; a simple list has none.
  2. 2 — Selected fill. One fill, drawn by the list, that moves to the tab you pick. In a track it sits 2px inside, its corners 2 less than the track's.
  3. 3 — Count. Plain text a size under the label.
  4. 4 — Icon. Before the label, in the label's color.
  5. 5 — Label. Full color when selected, secondary otherwise.

Variants

simple, the default: the selected tab takes a quiet fill, with no track. segment: a picker in a track, built as the secondary Button. line is the older underlined row, being phased out.

1<TabsList variant="simple">…</TabsList>2<TabsList variant="segment">…</TabsList>

Sizes

Four, matching the control scale: md, sm, xs, and xxs. A segment's track is 32, 28, 24, and 20px tall; a simple tab follows the same scale.

1<TabsList variant="segment" size="md">…</TabsList>2<TabsList variant="segment" size="sm">…</TabsList>3<TabsList variant="segment" size="xs">…</TabsList>4<TabsList variant="segment" size="xxs">…</TabsList>

Width

hug, the default: each tab as wide as its content. fill: the list takes its container and the tabs share it equally.

1<TabsList variant="segment" width="fill">…</TabsList>

Icons

iconStart puts an icon before the label. With iconOnly the icon shows alone: the label becomes the tab's tooltip (above, or to the right in vertical tabs) and stays its name for a screen reader.

1<TabsTrigger value="overview" iconStart={House}>Overview</TabsTrigger>2<TabsTrigger value="grants" iconStart={Key}>Grants</TabsTrigger>3<TabsTrigger value="security" iconStart={Shield}>Security</TabsTrigger>4 5<TabsTrigger value="list" iconStart={ListBullets} iconOnly>List</TabsTrigger>6<TabsTrigger value="grid" iconStart={Grid} iconOnly>Grid</TabsTrigger>

Counts

count ends a tab in plain text, a size under the label: muted, or with countColor a status's text color. A number is grouped for the reader (1,204). New, not used by a screen yet: a string is shown as it is ("99+"). The dashboard's own wrapper (components/ui/tabs.tsx) still takes a number only.

1<TabsTrigger value="all" count={1204}>All</TabsTrigger>2<TabsTrigger value="failed" count={3} countColor="error">Failed</TabsTrigger>3<TabsTrigger value="queued" count="99+">Queued</TabsTrigger>

A badge

badge ends a tab in a Badge, in the Badge's own shape (label, color, emphasis, icons, title). The tab sizes it: the 20px badge in a tab 28px tall or more, the 16px one under that. The badge sits as far from the tab's end as from its top and bottom: 6px in a 32px tab, 4px in a 28px or 24px one, 2px in a 20px one. The smallest segment tab is as tall as its badge, which keeps 2px from the tab's end. A tab without a badge keeps its own padding. No screen has a tab with a badge today. Below, each size as simple tabs and as a segment.

1<TabsTrigger value="all">All</TabsTrigger>2<TabsTrigger value="managed" badge={{ label: "Preview", color: "info" }}>Managed</TabsTrigger>3<TabsTrigger value="external">External</TabsTrigger>

An info icon

iconTooltip puts a small info icon after the label, with a few words on hover. Only a pointer reaches it; see the open question.

1<TabsTrigger value="written">Written</TabsTrigger>2<TabsTrigger value="effective" iconTooltip="What applies after every scope is merged.">Effective</TabsTrigger>

A tab to something dangerous

variant="destructive" is a tab that leads to something dangerous (a Danger zone): red text at rest, on hover and selected, over a tint of that red under the pointer (the red ghost Button's). A simple tab's selected fill is tinted red too, a step stronger; a selected segment tab changes its text only.

1<TabsTrigger value="general">General</TabsTrigger>2<TabsTrigger value="members">Members</TabsTrigger>3<TabsTrigger value="danger" variant="destructive">Danger zone</TabsTrigger>

Vertical

The same tabs in a column.

1<Tabs orientation="vertical" defaultValue="general">2  <TabsList aria-label="Settings">3    <TabsTrigger value="general">General</TabsTrigger>4    <TabsTrigger value="members">Members</TabsTrigger>5    <TabsTrigger value="billing">Billing</TabsTrigger>6  </TabsList>7</Tabs>

Motion

The selected fill is drawn once by the list and moves between tabs. auto, the default, slides it to a near tab and fades it to a far one (past slideDistance, 240px). slide and fade force one; none cuts, and so does reduced motion.

1<TabsList motion="auto">…</TabsList>2<TabsList motion="none">…</TabsList>

In the dashboard

Where tabs are drawn today. The first two are not this component underneath: they are links and buttons in its classes. Sections and the Docs switch change the address; the two splits change a value in place.

Audit's sections

Overview, Activity chains, Event log, Resource directory. Each is a link with its own address: SegmentedTabNav draws links in the Tabs' simple look.

components/layout/segmented-tab-nav.tsx

An agent's sections

Overview, Runs, Topology, Guards, Security, Settings. DetailPageView draws its own tab list in the Tabs' classes; each tab is a link, or a button that sets the address's hash.

components/layout/detail-page-view.tsx

A list's split

All, Managed, External over the agents: a segment today. The ds Table draws the same split as simple tabs at its bar's left.

components/agents/agent-table.tsx

A feed's result

All, Allowed, Denied, Errors over an agent's activity: a segment, Allowed's count in green, Denied's and Errors' in red.

components/agents/activity-feed.tsx

Docs or Playground

The switch at the top of this page: a small segment whose two tabs are two addresses.

catalog/app/_components/catalog-mode.tsx

Accessibility

Base UI gives the roles: a tab list, its tabs, and a panel tied to each tab, the selected one marked. The list has no name unless you give it one with aria-label; the activity feed's has none today.

The Tab key enters the row on the selected tab. Inside the row the arrow keys move between tabs, Home and End jump to the first and last, and the row wraps at its ends. An arrow moves the focus and does not select: Enter or Space selects. activateOnFocus on the list makes arrows select as they move.

An icon-only tab keeps its label as its name. A count is inside the tab, so it is part of the name: "Failed 3". A badge is decoration and is not: a tab named "Managed" stays "Managed".

What does not hold up today: the info icon of iconTooltip is reached by a pointer only. The open panel takes focus and draws no ring. And the small tabs are under the 24px that WCAG 2.2 asks of a pointer target: an xs segment tab and an xxs simple tab are 20px tall, an xxs segment tab 16px.

API Reference

Tabs

PropTypeDefaultDescription
defaultValuestring—The tab selected at first. Without it the first enabled tab is selected.
value / onValueChangestring / (value) => void—The selection, held by you.
orientation"horizontal" | "vertical""horizontal"A row, or a column.

TabsList

PropTypeDefaultDescription
variant"simple" | "segment" | "line""simple"No track, a track, or the older underlined row.
size"lg" | "md" | "sm" | "xs" | "xxs""md"In a card's header, toolbar or footer it is 28px at most.
width"hug" | "fill""hug"Each tab its content's width, or the tabs sharing the container.
motion"auto" | "slide" | "fade" | "none""auto"How the selected fill moves to the next tab.
slideDistancenumber240Under auto, how far the fill slides before it fades instead, in px.
activateOnFocusbooleanfalseArrows select as they move, instead of waiting for Enter or Space.
aria-labelstring—The list's name for a screen reader.

TabsTrigger

PropTypeDefaultDescription
valuestring—Which panel it shows.
iconStartIconComponent—An icon before the label.
dot{ color?, size?, halo?, haloSize?, pulse? }—A Status dot before the label, in the icon's place and its box (14px, 10px in an xxs tab). With a dot, iconStart is not drawn and iconOnly does nothing.
iconOnlyboolean | tooltip settings—With iconStart: the icon alone, the label as its tooltip and its name.
iconTooltipstring | tooltip settings—An info icon after the label, with text on hover. Not on an icon-only tab.
countnumber | string—A count after the label. A number is grouped for the reader. The string form is new and no screen uses it yet.
countColorBadgeColor"neutral"A status's text color for the count.
badgeBadgeSpec—A Badge at the tab's end: { label, color?, emphasis?, iconStart?, iconEnd?, title? }. Not in the tab's name.
variant"default" | "destructive""default"destructive: a tab that leads to something dangerous (a Danger zone), in red.
disabledboolean—The tab cannot be selected.

TabsContent

PropTypeDefaultDescription
valuestring—The tab it belongs to.
keepMountedbooleanfalseKeep the panel in the page while another is shown, with its state.

Rules

Written down

28px at most in a card's header, toolbar or footer

A list asked for at medium renders small there. The list does it itself; nothing is set per screen.

From ds/README.md (Card) and ds/lib/size-cap.tsx.

A table's one split is its tabs

A split like All / Managed / External is the tabs at the left of the table's bar, after the title: it filters, with no chip. Everything else that narrows the list is the Filter. Short of room, those tabs become one select.

From the Table's rules (T10, T13).

Red is a tab that leads to something dangerous

variant="destructive" is for a Danger zone tab.

From ds/components/tabs.tsx.

line is being phased out

The underlined row stays for what already uses it. The dashboard's own Tabs map it to simple under the new design.

From ds/components/tabs.tsx and ds/README.md.

Open questions

Tabs, or a toggle group, for a value changed in place?

Open
Ours

The README says: Tabs move you somewhere (a section, a URL, the panel below), a toggle group changes a value in place (a filter, a view, a unit), and "Dome uses Tabs for both today". The ds has a ToggleGroup. For a table's split the answer is written (tabs); outside a table, nothing written chooses.

Other systems

Primer's segmented control is not announced as a tab list. Atlassian says not to use tabs for filtering data within a single table. Polaris shows tabs over a list view with different filters applied.

A row of links, or Tabs, when the address changes?

Open
Ours

The product does three things: Audit's sections are links (SegmentedTabNav), an agent's sections are a hand-built tab list of links and hash buttons (DetailPageView), and the Docs switch is Tabs that navigate. Nothing written chooses.

Other systems

Primer keeps tabs that change the URL in a separate navigation component, made of links. Base UI and Polaris let a tab be a link.

Should an arrow key select the tab it lands on?

Open
Ours

It does not: an arrow moves the focus and Enter or Space selects, which is Base UI's default. No screen turns the other way on.

Other systems

Atlassian selects on focus. Primer selects on focus by default, and offers the manual way for panels that do not show at once.

What happens when the tabs do not fit?

Open
Ours

Nothing: the row keeps its width and no tab wraps or hides. The one exception is a table's bar, where the tabs become one select.

Other systems

Primer moves the tabs that do not fit into a menu, and can drop their icons when narrow. Polaris measures the tabs and puts the rest in a popover.

An info icon in a tab?

Open
Ours

iconTooltip exists and only a pointer reaches it.

Other systems

They disagree. Primer: don't rely on icons or tooltips to explain a tab. Atlassian: a tooltip can say what happens when the tab is selected.

What others advise

None of this is decided for us. It is what Atlassian, Polaris and Primer tell their own teams, listed so you can pick.

Others adviseWho
Don't use tabs as primary navigation, or to move between different pages.Polaris, Atlassian
Each tab's content stands alone: nobody should have to switch tabs to finish one task.Polaris, Primer
What relates to every tab goes above the row.Atlassian
One tab is selected when the row first shows.Primer
Order tabs by importance or by how often they are used.Atlassian
Labels of one or two words (Atlassian), a single word where possible (Polaris).Atlassian, Polaris
Icons on every tab of a row, or on none.Primer
A segmented control holds two to five text options, or up to six icons; past that, a radio group or a menu.Primer
Tabs sit directly above their content, and are no wider than it.Primer

What others expose

What Base UI, Atlassian, Polaris and Primer offer for tabs, and where ours stands on each.

They exposeOursWhy
A count given as text (Primer, Polaris)AddedNew, not used by a screen yet: count takes a string.
Arrows that select as they move (Base UI, Primer, Atlassian)Already thereactivateOnFocus on the list.
A marker that follows the selected tab (Base UI)Already thereThe list's fill and its motion.
Tabs that share the width (Polaris)Already therewidth="fill".
Hidden panels kept in the page (Base UI)Already therekeepMounted on TabsContent.
A tab that is a link (Base UI, Polaris)AskNot on the ds Tabs. SegmentedTabNav and DetailPageView each draw their own.
A menu for the tabs that do not fit, and icons dropped when narrow (Primer, Polaris)AskOnly the Table's bar gives way today.
A placeholder for counts that are still loading (Primer)AskPrimer itself says to avoid it until its accessibility issues are resolved.
Actions on a tab: rename, duplicate, delete (Polaris)AskThe dashboard has no saved views today.
Catalog
Foundations
  • Overview
  • Components
  • Tokens
  • Token usage
  • Typography
  • Icons
Atoms
  • Avatar
  • Badge
  • Button
  • Checkbox
  • Color picker
  • Copy button
  • Icon tooltip
  • Inline code
  • Input
  • Hint
  • Kbd
  • Loader
  • Native select
  • Progress bar
  • Progress ring
  • Radio
  • Select
  • Status dot
  • Switch
  • Text link
  • Textarea
  • Tooltip
  • Truncate
Molecules
  • Accordion
  • Activity chart
  • AI elements
  • Alert
  • Button group
  • Card
  • Code block
  • Combobox trigger
  • Command
  • Content table
  • Context switcher
  • Dropdown menu
  • Empty state
  • Field
  • Field group
  • Filter chip
  • Flow
  • Heading
  • Icon picker
  • Icon flow card
  • Metric card
  • Modal
  • Modal confirmation
  • Pagination
  • Popover
  • Scroll area
  • Sidebar
  • Table
  • Tabs
  • Toggle group
LibraryPublished release