|Kit

Tabs

A navigation control on Ark UI's Tabs machine — a row (or column) of triggers over a hairline baseline, each revealing its own content panel, with an underline or an enclosed box that slides to the active trigger.

Tabs is a navigation control: a row (or column) of triggers over a hairline baseline that spans the whole strip, each trigger revealing its own content panel. An indicator slides to the active trigger: an underline by default, or an enclosed box attached to the panel. Tabs is navigation, not a form control, so it has no Field integration.

Looking for a segmented pill tray? That's SegmentGroup: a single-choice value with the filled / light / outline / subtle / default variants. Tabs dropped that look in favor of these two classic treatments.

import { Tabs } from '@42-central/ui-react/tabs';

<Tabs
  defaultValue="overview"
  data={[
    { value: 'overview', label: 'Overview', content: <Overview /> },
    { value: 'activity', label: 'Activity', content: <Activity /> },
  ]}
/>

Playground

Component

Loading preview

Props

Code

<Component orientation="horizontal" size="md" />

Items

data is a flat array of { value, label, content, disabled?, color? } — each tab needs its own content, so (unlike SegmentGroup) there's no bare-string shorthand.

<Tabs
  defaultValue="overview"
  data={[
    { value: 'overview', label: 'Overview', content: <Overview /> },
    { value: 'activity', label: 'Activity', content: <Activity /> },
    { value: 'settings', label: 'Settings', content: <Settings />, disabled: true },
  ]}
/>

Each item also accepts an optional testId, defaulting to `tab-${value}` — the matching content panel gets `${testId}-panel`. See the Testing guide. The compound Tabs.Trigger / Tabs.Content / Tabs.List / Tabs.Root / Tabs.Indicator parts each take their own testId prop directly, for the same reason.

Variants

Two treatments. underline (the default) draws a 2px bar on the baseline under the active tab. enclosed turns the active tab into a hairline box open at the bottom, so it reads as attached to its panel.

A
A

Code

<Tabs defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} />
<Tabs variant="enclosed" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} />

On any surface

Neither variant paints a background. The enclosed box draws the baseline itself, running out from its two bottom corners to the ends of the list, so the line is open under the active tab without covering anything: the strip reads the same on a Card or a tinted panel as on the page.

A
A

Code

<div className="flex w-full flex-col gap-4">
  <Card><Tabs variant="enclosed" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} /></Card>
  <Card variant="light" color="green"><Tabs variant="enclosed" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} /></Card>
</div>

Sizes

Five sizes — xs through xl — matching the rest of the family. Sizing lives on the triggers; the gap between them scales alongside.

A
A
A
A
A

Code

<Tabs size="xs" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }]} />
<Tabs size="sm" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }]} />
<Tabs size="md" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }]} />
<Tabs size="lg" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }]} />
<Tabs size="xl" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }]} />

Colors

Without a color, the strip is neutral: the resting labels are the secondary text color, and the bar and the active label the primary one. With a color, the active label takes the palette's text color and the underline bar its solid color; the resting labels stay neutral. color is scoped to the tab strip: it does not tint whatever your panels render, so a Button inside a panel keeps its own palette.

A
A
A
A
A

Code

<Tabs color="neutral" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} />
<Tabs color="brand" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} />
<Tabs color="green" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} />
<Tabs color="orange" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} />
<Tabs color="red" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} />

Per-tab color

Give an item its own color (or Tabs.Trigger a color prop) to tint that tab alone. Its selected label takes the palette, and the indicator switches palette with the selection, cross-fading as it slides. A tab's color beats the color prop; a tab without one falls back to it, or stays neutral.

7 validated
7 validated

Code

<Tabs defaultValue="validated" data={[{ value: 'all', label: 'All', content: '12 projects' }, { value: 'validated', label: 'Validated', content: '7 validated', color: 'green' }, { value: 'waiting', label: 'Waiting', content: '3 waiting', color: 'orange' }, { value: 'failed', label: 'Failed', content: '2 failed', color: 'red' }]} />
<Tabs variant="enclosed" defaultValue="validated" data={[{ value: 'all', label: 'All', content: '12 projects' }, { value: 'validated', label: 'Validated', content: '7 validated', color: 'green' }, { value: 'waiting', label: 'Waiting', content: '3 waiting', color: 'orange' }, { value: 'failed', label: 'Failed', content: '2 failed', color: 'red' }]} />

Full width

Set grow to give every tab an even share of the strip, like a tab bar. On the compound API it lives on Tabs.List. The indicator follows the active tab as the strip resizes.

A
A

Code

<Tabs grow defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} />
<Tabs grow variant="enclosed" defaultValue="a" data={[{ value: 'a', label: 'Overview', content: 'A' }, { value: 'b', label: 'Activity', content: 'B' }, { value: 'c', label: 'Settings', content: 'C' }]} />

Orientation

Set orientation="vertical" to stack the triggers in a column, with the panels beside it instead of below. The baseline moves to the list's inline-end edge (the left edge in a right-to-left locale), between the triggers and the panels, and the underline and the enclosed box follow it.

A quick summary of the project — status, owners, and the last update.
A quick summary of the project — status, owners, and the last update.

Disabled tab

A single tab can be disabled via { value, label, content, disabled: true }. It's skipped by keyboard navigation and can't be clicked.

Available to everyone.

Compound API

Drop to the composable parts for anything the flat data array can't express — custom trigger content, interleaved non-tab elements, or driving the value from your own state. variant, size, color and grow all live on Tabs.List and apply to the baseline, every trigger, and the indicator. color is a data-color attribute on the list specifically — putting it on Tabs.Root would also cover every Tabs.Content, leaking the palette into your panel content.

'use client';
import { Tabs } from '@42-central/ui-react/tabs';

<Tabs.Root defaultValue="overview">
  <Tabs.List variant="enclosed" color="brand">
    <Tabs.Indicator />
    <Tabs.Trigger value="overview">Overview</Tabs.Trigger>
    <Tabs.Trigger value="activity">Activity</Tabs.Trigger>
  </Tabs.List>
  <Tabs.Content value="overview"><Overview /></Tabs.Content>
  <Tabs.Content value="activity"><Activity /></Tabs.Content>
</Tabs.Root>

Controlled

Drive the value from state. onChange hands you the selected value directly (the data-driven form); the compound Tabs.Root takes Ark's own value / onValueChange.

'use client';
import { useState } from 'react';
import { Tabs } from '@42-central/ui-react/tabs';

export function ProjectTabs() {
  const [tab, setTab] = useState('overview');
  return (
    <Tabs
      value={tab}
      onChange={setTab}
      data={[
        { value: 'overview', label: 'Overview', content: <Overview /> },
        { value: 'activity', label: 'Activity', content: <Activity /> },
      ]}
    />
  );
}

API

Prop

Type

Accessibility

  • Built on Ark UI's Tabs machine: role="tablist" / "tab" / "tabpanel", with aria-selected and roving tabIndex on the triggers and aria-controls / aria-labelledby linking each trigger to its panel.
  • ← / → (or ↑ / ↓ when orientation="vertical") move focus between triggers; activationMode="automatic" (the default) activates the focused tab immediately, "manual" waits for Enter / a click. Tab enters and leaves the tablist as a single stop.
  • A disabled trigger is skipped by arrow-key navigation and unclickable.
  • RTL is honored via the document dir.
  • The indicator slides over --duration-normal on --ease-emphasized; under prefers-reduced-motion: reduce it jumps to the new tab instead.

Changelog

v0.29.0
  • No computed-style read on mount in production: the RTL direction check runs in development only

    #464
v0.26.0
  • grow gives every item an even share of the row

    #447
v0.20.0
  • The filled, light, outline, subtle and default variants are replaced by underline (the new default) and enclosed on a full-width baseline; use SegmentGroup for the pill look

    #378
  • Give one tab its own palette with color on Tabs.Trigger or a data item; the underline recolors as it slides

    #378
  • The active tab is marked in the server HTML before hydration

    #378
  • The sliding indicator holds still under reduced motion, and a consumer className overrides the part's own utilities

    #389
v0.19.0
  • The default ThemeIcon and the filled Tabs and SegmentGroup tray use the kit's hairline border and quiet fill instead of the gray scale

    #316
  • Right to left, Tabs and SegmentGroup separators sit between the items, and Table headers align to the start with scroll fades on the correct edge

    #331
v0.18.0
  • asChild is a compile error on the data forms of Accordion, Tabs and Breadcrumb, on the ready-made Notification and on AppShell.Sidebar (their Root parts keep it)

    #294
  • The data form's onChange is typed with your tab values only, no longer widened by the native ChangeEvent

    #294
v0.9.2
  • color moves from Tabs.Root to Tabs.List, so it no longer tints panel content

    #143
  • The selected label follows its pill's palette, staying legible on colored strips and while hovered

    #143
v0.7.0
  • The sliding indicator matches SegmentGroup's, and the default variant tints with --c-solid

    #109
v0.5.0
  • New Tabs component, with a sliding pill indicator

    #60

On this page