Tabs

A set of layered panels where only one is visible at a time.

Import

import { Tabs } from '@matix/components/tabs';

Usage

Manage your account settings and preferences.

Controlled

Use value and onValueChange for controlled tab selection.

import { useState } from 'react';

function ControlledTabs() {
  const [tab, setTab] = useState('one');
  return (
    <div>
      <Tabs.Root value={tab} onValueChange={setTab}>
        <Tabs.List>
          <Tabs.Tab value="one">Tab One</Tabs.Tab>
          <Tabs.Tab value="two">Tab Two</Tabs.Tab>
        </Tabs.List>
        <Tabs.Panel value="one">First panel content.</Tabs.Panel>
        <Tabs.Panel value="two">Second panel content.</Tabs.Panel>
      </Tabs.Root>
      <span>Active: {tab}</span>
    </div>
  );
}

Pill Variant

Set variant="pill" on Tabs.List for a segmented-control look with a raised active pill. Each Tabs.Tab takes the variant from its list through CSS, so you set it once.

A high-level view of your workspace.

A variant on one Tabs.Tab overrides the list variant for that tab only.

Vertical

Set orientation="vertical" on Tabs.Root to put the tabs in a column beside the panel. The active tab shows its indicator on the inline end, so it moves to the left side in RTL. ArrowUp and ArrowDown move between the tabs. Both variants support it.

Name, URL, and default language.

Keyboard Activation

An arrow key moves focus to the next tab and selects it at the same time. This is the WAI-ARIA "automatic activation" pattern, and Radix tabs do the same. matix sets activateOnFocus on Tabs.List to true by default. Base UI uses false by default.

If a panel is slow to render, set activateOnFocus={false}. Then the arrow keys only move focus, and Enter or Space selects the focused tab.

<Tabs.List activateOnFocus={false}>
  <Tabs.Tab value="report">Report</Tabs.Tab>
  <Tabs.Tab value="raw">Raw data</Tabs.Tab>
</Tabs.List>

Disabled Tab

Individual tabs can be disabled while the rest remain interactive.

This tab is active.

Custom Styles

Use the sx prop on any sub-component to override styles.

import * as stylex from '@stylexjs/stylex';

const custom = stylex.create({
  list: { borderBottom: '2px solid #e2e8f0' },
  tab: { fontWeight: 600, letterSpacing: '-0.01em' },
  panel: { padding: '16px 0' },
});

<Tabs.Root defaultValue="one">
  <Tabs.List sx={custom.list}>
    <Tabs.Tab value="one" sx={custom.tab}>
      First
    </Tabs.Tab>
    <Tabs.Tab value="two" sx={custom.tab}>
      Second
    </Tabs.Tab>
  </Tabs.List>
  <Tabs.Panel value="one" sx={custom.panel}>
    Styled first panel.
  </Tabs.Panel>
  <Tabs.Panel value="two" sx={custom.panel}>
    Styled second panel.
  </Tabs.Panel>
</Tabs.Root>;

Server Components

Tabs is a client component. A Server Component cannot read a property of a client component, so Tabs.Root is undefined there. In a Server Component, import the named parts. Each Tabs.<Part> is also exported as Tabs<Part>.

import { TabsRoot, TabsList, TabsTab, TabsPanel } from '@matix/components/tabs';

In a client component, both forms work.

API Reference

ComponentPropTypeDefaultDescription
Tabs.RootdefaultValuestring—Initially active tab (uncontrolled)
Tabs.Rootvaluestring—Active tab (controlled)
Tabs.RootonValueChange(value: string) => void—Called when the active tab changes
Tabs.Rootorientation'horizontal' | 'vertical''horizontal'Lays the tabs out in a row or a column
Tabs.RootsxStyleXStyles—StyleX style override
Tabs.Listvariant'line' | 'pill''line'Visual style. The tabs in the list take it too
Tabs.ListactivateOnFocusbooleantrueSelect a tab when an arrow key focuses it
Tabs.ListsxStyleXStyles—StyleX style override
Tabs.Tabvaluestring—Unique identifier for the tab
Tabs.Tabvariant'line' | 'pill'—Overrides the list variant for this tab
Tabs.TabdisabledbooleanfalseDisables the tab
Tabs.TabsxStyleXStyles—StyleX style override
Tabs.Panelvaluestring—Matches the corresponding Tabs.Tab value
Tabs.PanelsxStyleXStyles—StyleX style override

All other props on each sub-component are forwarded to the underlying Base UI element.

Accessibility

  • Built on Base UI Tabs — implements WAI-ARIA Tabs pattern with role="tablist", role="tab", and role="tabpanel".
  • Each tab is associated with its panel via aria-controls and aria-labelledby.
  • Selected tab receives aria-selected="true".
  • Disabled tabs are excluded from the tab sequence and marked with aria-disabled.
  • Focus ring is visible on keyboard navigation only (:focus-visible).

Keyboard

KeyAction
ArrowRightMoves focus to the next tab and selects it
ArrowLeftMoves focus to the previous tab and selects it
ArrowDown / ArrowUpThe same, when orientation="vertical"
HomeMoves focus to the first tab and selects it
EndMoves focus to the last tab and selects it
Enter / SpaceActivates the focused tab

With activateOnFocus={false}, the arrow keys, Home, and End only move focus.