Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Navigation

Tabs

Free4.1 KB gzipped

Tabs root. See TabsProps; compose with Tabs.List, Tabs.Tab, and Tabs.Panel.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Arrow Right, Arrow Left, Arrow Down and 6 more · Full report

Import

tsx
import { Tabs } from "@vjdesigns/vjdesigns-ui";

Importing only Tabs adds about 4.1 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

Arrow keys move between tabs, and the selected tab's panel shows.

Project summary, goals and key dates.

tsx
import { Tabs, Text } from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  return (
    <Tabs defaultValue="overview" style={{ width: "100%" }}>
      <Tabs.List aria-label="Project">
        <Tabs.Tab value="overview">Overview</Tabs.Tab>
        <Tabs.Tab value="activity">Activity</Tabs.Tab>
        <Tabs.Tab value="settings">Settings</Tabs.Tab>
      </Tabs.List>
      <Tabs.Panel value="overview">
        <Text tone="muted">Project summary, goals and key dates.</Text>
      </Tabs.Panel>
      <Tabs.Panel value="activity">
        <Text tone="muted">Recent comments, uploads and status changes.</Text>
      </Tabs.Panel>
      <Tabs.Panel value="settings">
        <Text tone="muted">Visibility, members and integrations.</Text>
      </Tabs.Panel>
    </Tabs>
  );
}

Variants

variant changes the look: line (default), pill or enclosed. Tabs can carry an icon and a badge.

Name, email and password.

tsx
import {
  Badge,
  BellIcon,
  SettingsIcon,
  Tabs,
  Text,
  UserIcon,
} from "@vjdesigns/vjdesigns-ui";

export function Variants() {
  return (
    <Tabs defaultValue="account" variant="pill" style={{ width: "100%" }}>
      <Tabs.List aria-label="Settings">
        <Tabs.Tab value="account" icon={<UserIcon />}>
          Account
        </Tabs.Tab>
        <Tabs.Tab value="alerts" icon={<BellIcon />} badge={<Badge tone="primary" variant="solid" size="sm" count={4} label="4 new" />}>
          Alerts
        </Tabs.Tab>
        <Tabs.Tab value="advanced" icon={<SettingsIcon />}>
          Advanced
        </Tabs.Tab>
      </Tabs.List>
      <Tabs.Panel value="account">
        <Text tone="muted">Name, email and password.</Text>
      </Tabs.Panel>
      <Tabs.Panel value="alerts">
        <Text tone="muted">You have 4 new alerts.</Text>
      </Tabs.Panel>
      <Tabs.Panel value="advanced">
        <Text tone="muted">API keys and data export.</Text>
      </Tabs.Panel>
    </Tabs>
  );
}

Vertical

Language, time zone and start page.

tsx
import { Tabs, Text } from "@vjdesigns/vjdesigns-ui";

export function Vertical() {
  return (
    <Tabs defaultValue="general" orientation="vertical" variant="enclosed" style={{ width: "100%" }}>
      <Tabs.List aria-label="Preferences">
        <Tabs.Tab value="general">General</Tabs.Tab>
        <Tabs.Tab value="privacy">Privacy</Tabs.Tab>
        <Tabs.Tab value="billing" disabled>
          Billing
        </Tabs.Tab>
      </Tabs.List>
      <Tabs.Panel value="general">
        <Text tone="muted">Language, time zone and start page.</Text>
      </Tabs.Panel>
      <Tabs.Panel value="privacy">
        <Text tone="muted">Who can see your profile and activity.</Text>
      </Tabs.Panel>
      <Tabs.Panel value="billing" />
    </Tabs>
  );
}

Accessibility

Tabs follow the WAI-ARIA tabs pattern: Tab moves into the tab list and then to the panel, and the arrow keys move between tabs. With activationMode="manual", arrows only move focus and Enter or Space selects, which suits panels that are slow to load. A badge needs badgeLabel, so "3" is read as "3 unread".

You have 3 new messages.

tsx
import { Tabs, Text } from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  return (
    <Tabs defaultValue="inbox" activationMode="manual" style={{ width: "100%", maxWidth: "30rem" }}>
      <Tabs.List>
        <Tabs.Tab value="inbox" badge={3} badgeLabel="3 unread">
          Inbox
        </Tabs.Tab>
        <Tabs.Tab value="sent">Sent</Tabs.Tab>
        <Tabs.Tab value="spam" disabled>
          Spam
        </Tabs.Tab>
      </Tabs.List>
      <Tabs.Panel value="inbox">
        <Text>You have 3 new messages.</Text>
      </Tabs.Panel>
      <Tabs.Panel value="sent">
        <Text>Nothing sent this week.</Text>
      </Tabs.Panel>
      <Tabs.Panel value="spam">
        <Text>Spam is empty.</Text>
      </Tabs.Panel>
    </Tabs>
  );
}

Translated

In Arabic the tabs run right to left and the arrow keys follow the reading direction. The tab labels are your own text.

معلومات حسابك الأساسية.

tsx
import { Tabs, Text, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

export function Translated() {
  return (
    <LocaleProvider locale="ar" messages={ar}>
      <Tabs defaultValue="account" style={{ width: "100%", maxWidth: "30rem" }}>
        <Tabs.List>
          <Tabs.Tab value="account">الحساب</Tabs.Tab>
          <Tabs.Tab value="billing">الفوترة</Tabs.Tab>
          <Tabs.Tab value="security">الأمان</Tabs.Tab>
        </Tabs.List>
        <Tabs.Panel value="account">
          <Text>معلومات حسابك الأساسية.</Text>
        </Tabs.Panel>
        <Tabs.Panel value="billing">
          <Text>طرق الدفع والفواتير.</Text>
        </Tabs.Panel>
        <Tabs.Panel value="security">
          <Text>كلمة المرور والتحقق بخطوتين.</Text>
        </Tabs.Panel>
      </Tabs>
    </LocaleProvider>
  );
}

API reference

Tabs

Tabs props
PropTypeDefault
value

Selected tab value (controlled). Use with onValueChange.

string—
defaultValue

Initially selected tab value (uncontrolled). When omitted, the first enabled tab starts selected.

string—
onValueChange

Called with the newly selected tab's value.

(value: string) => void—
variant

Visual style of the tab list. See TabsVariant.

"line""pill""enclosed""line"
size

Tab height, padding, and type size.

"sm""md""lg""md"
orientation

Tabs in a row above the panels, or in a column beside them. Sets aria-orientation and the arrow keys.

"horizontal""vertical""horizontal"
activationMode

Whether arrow keys also select (automatic) or only move focus (manual, select with Enter or Space).

"automatic""manual""automatic"
fullWidth

Stretch the tabs to share the list's full width equally (horizontal only).

booleanfalse
keepMounted

Keep inactive panels mounted (hidden with the hidden attribute) so their state survives tab switches. By default only the active panel renders. Tabs.Panel can override this per panel.

booleanfalse
children

Tabs.List and Tabs.Panel parts.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

Tabs.List

The tablist that holds the tabs.

Tabs.List props
PropTypeDefault
children

Tabs.Tab children. Name the list with aria-label or aria-labelledby when the page has more than one tab set or no heading names it.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

Tabs.Tab

One tab button.

Tabs.Tab props
PropTypeDefault
valueRequired

Identifies the tab and matches it to the Tabs.Panel with the same value. Tab and panel ids are generated from it; if you pass your own id, give the panel a matching aria-labelledby.

string—
icon

Decorative icon before the label (e.g. <Icon name="settings" />).

ReactNode—
badge

Trailing count or tag. A number renders a small Badge (accent when the tab is selected, neutral otherwise); any other node renders as given. A 0 count is hidden.

ReactNode—
badgeLabel

Screen-reader text for a numeric badge, e.g. "3 unread", so the tab is not announced as a bare number.

string—
disabled

Disables the tab. Arrow keys, Home, and End skip it.

boolean—
children

Visible tab label.

NonNullable<ReactNode>—
aria-label

Overrides the accessible name (rarely needed).

string—

Also accepts standard HTML attributes, plus className, style and ref.

Tabs.Panel

The content panel for one tab.

Tabs.Panel props
PropTypeDefault
valueRequired

The value of the Tabs.Tab this panel belongs to.

string—
keepMounted

Keep this panel mounted (hidden) while inactive. Overrides Tabs's keepMounted.

boolean—
children

Panel content.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

Tabs targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
Arrow RightArrow LeftHorizontal: next or previous tab, wrapping (mirrored right to left).
Arrow DownArrow UpVertical: next or previous tab, wrapping.
HomeEndFirst or last tab.
EnterSpaceactivationMode="manual": selects the focused tab. Automatic (default) selects as focus moves.
TabFrom the tab list, moves into the selected panel.

One tab stop in the tab list (roving tabindex).

Roles and states

Roles and states
ElementRoleStates and properties
Tabs.Listtablistaria-orientation, aria-label
Tabs.Tabtabaria-selected, aria-controls → panel
Tabs.Paneltabpanelaria-labelledby → tab, tabindex="0"

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)