Navigation
Tabs
Free4.1 KB gzippedTabs 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
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.
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.
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.
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.
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.
معلومات حسابك الأساسية.
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
| Prop | Type | Default |
|---|---|---|
valueSelected tab value (controlled). Use with | string | — |
defaultValueInitially selected tab value (uncontrolled). When omitted, the first enabled tab starts selected. | string | — |
onValueChangeCalled with the newly selected tab's | (value: string) => void | — |
variantVisual style of the tab list. See | "line""pill""enclosed" | "line" |
sizeTab height, padding, and type size. | "sm""md""lg" | "md" |
orientationTabs in a row above the panels, or in a column beside them. Sets | "horizontal""vertical" | "horizontal" |
activationModeWhether arrow keys also select ( | "automatic""manual" | "automatic" |
fullWidthStretch the tabs to share the list's full width equally (horizontal only). | boolean | false |
keepMountedKeep inactive panels mounted (hidden with the | boolean | false |
children
| ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
Tabs.List
The tablist that holds the tabs.
| Prop | Type | Default |
|---|---|---|
children
| ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
Tabs.Tab
One tab button.
| Prop | Type | Default |
|---|---|---|
valueRequiredIdentifies the tab and matches it to the | string | — |
iconDecorative icon before the label (e.g. | ReactNode | — |
badgeTrailing count or tag. A number renders a small | ReactNode | — |
badgeLabelScreen-reader text for a numeric | string | — |
disabledDisables the tab. Arrow keys, Home, and End skip it. | boolean | — |
childrenVisible tab label. | NonNullable<ReactNode> | — |
aria-labelOverrides the accessible name (rarely needed). | string | — |
Also accepts standard HTML attributes, plus className, style and ref.
Tabs.Panel
The content panel for one tab.
| Prop | Type | Default |
|---|---|---|
valueRequiredThe | string | — |
keepMountedKeep this panel mounted (hidden) while inactive. Overrides | boolean | — |
childrenPanel 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)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 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
| Key | Action |
|---|---|
| Arrow RightArrow Left | Horizontal: next or previous tab, wrapping (mirrored right to left). |
| Arrow DownArrow Up | Vertical: next or previous tab, wrapping. |
| HomeEnd | First or last tab. |
| EnterSpace | activationMode="manual": selects the focused tab. Automatic (default) selects as focus moves. |
| Tab | From the tab list, moves into the selected panel. |
One tab stop in the tab list (roving tabindex).
Roles and states
| Element | Role | States and properties |
|---|---|---|
Tabs.List | tablist | aria-orientation, aria-label |
Tabs.Tab | tab | aria-selected, aria-controls → panel |
Tabs.Panel | tabpanel | aria-labelledby → tab, tabindex="0" |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every 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) |
| Focus | Focus 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 readers | Names, 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) |
| Color | Meaning 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 reflow | At 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 targets | Click 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) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |