Skip to content

TabList

TabList

A set of tabs with their panels (WAI-ARIA Tabs pattern): the arrow keys (Left/Right, mirrored in RTL; Up/Down when vertical), Home and End move focus and select (automatic activation); with selectTabOnFocus={false} they only move focus, and Enter, Space or a click selects the focused tab (manual activation). The selected tab is the only tab stop; disabled tabs are skipped. Every tab needs a value that is unique within the TabList (a development warning names a value that several tabs share).

Tabs register through context and are found in DOM order, so they may be wrapped (a Fragment, a Tooltip). The children render inside the role="tablist" element, except panels, which render after it: a TabList.Panel or TabList.Panels child, or a wrapper (an element, Suspense, an error boundary) that holds panels and no Tab. A Panel that a component renders itself cannot be seen from the children: put that component inside TabList.Panels (a development warning names a Panel that ends up inside the tablist). Content that is not a tab, such as a button next to the tabs, does not belong in a tablist either: render it outside the TabList.

In the transparent appearance the selected tab draws its line with its after pseudo-element, over a transparent 2px border on its bottom edge (its start edge when vertical), so the tab keeps the box it has without the line; a class that recolours the line targets that pseudo-element's border. When the selection moves, the line slides from the tab selected before (motion).

Sub-components are also exported under flat names (TabListTab, TabListPanel, TabListPanels) for React Server Components, which cannot use the dotted form.

Examples

Default

Content for Tab 1
export const Default: Story = {
  render: (args) => (
    <TabList {...args}>
      <TabList.Tab value="tab1">Tab 1</TabList.Tab>
      <TabList.Tab value="tab2">Tab 2</TabList.Tab>
      <TabList.Tab value="tab3">Tab 3</TabList.Tab>
      <TabList.Panel value="tab1">Content for Tab 1</TabList.Panel>
      <TabList.Panel value="tab2">Content for Tab 2</TabList.Panel>
      <TabList.Panel value="tab3">Content for Tab 3</TabList.Panel>
    </TabList>
  ),
};

Vertical

Profile content goes here.
export const Vertical: Story = {
  args: {
    'aria-label': 'Account',
    defaultValue: 'tab1',
    orientation: 'vertical',
  },
  render: (args) => (
    <TabList {...args}>
      <TabList.Tab value="tab1">Profile</TabList.Tab>
      <TabList.Tab value="tab2">Settings</TabList.Tab>
      <TabList.Tab value="tab3">Notifications</TabList.Tab>
      <TabList.Panel value="tab1">Profile content goes here.</TabList.Panel>
      <TabList.Panel value="tab2">Settings content goes here.</TabList.Panel>
      <TabList.Panel value="tab3">Notification preferences.</TabList.Panel>
    </TabList>
  ),
};

Controlled

Overview content.
export const Controlled: Story = {
  render: function ControlledTabList(args) {
    const [value, setValue] = React.useState('tab1');
    return (
      <TabList
        {...args}
        value={value}
        onValueChange={(next) => {
          setValue(next);
          args.onValueChange?.(next);
        }}
      >
        <TabList.Tab value="tab1">Overview</TabList.Tab>
        <TabList.Tab value="tab2">Details</TabList.Tab>
        <TabList.Tab value="tab3">History</TabList.Tab>
        <TabList.Panel value="tab1">Overview content.</TabList.Panel>
        <TabList.Panel value="tab2">Details content.</TabList.Panel>
        <TabList.Panel value="tab3">History content.</TabList.Panel>
      </TabList>
    );
  },
};

Manual Activation

Daily report.
export const ManualActivation: Story = {
  args: {
    'aria-label': 'Reports',
    defaultValue: 'tab1',
    selectTabOnFocus: false,
  },
  render: (args) => (
    <TabList {...args}>
      <TabList.Tab value="tab1">Daily</TabList.Tab>
      <TabList.Tab value="tab2">Weekly</TabList.Tab>
      <TabList.Tab value="tab3">Monthly</TabList.Tab>
      <TabList.Panel value="tab1">Daily report.</TabList.Panel>
      <TabList.Panel value="tab2">Weekly report.</TabList.Panel>
      <TabList.Panel value="tab3">Monthly report.</TabList.Panel>
    </TabList>
  ),
};

With Disabled Tab

Inbox messages.
export const WithDisabledTab: Story = {
  args: {
    defaultValue: 'tab1',
  },
  render: (args) => (
    <TabList {...args}>
      <TabList.Tab value="tab1">Inbox</TabList.Tab>
      <TabList.Tab value="tab2" disabled>
        Archive
      </TabList.Tab>
      <TabList.Tab value="tab3">Sent</TabList.Tab>
      <TabList.Panel value="tab1">Inbox messages.</TabList.Panel>
      <TabList.Panel value="tab2">Archived messages.</TabList.Panel>
      <TabList.Panel value="tab3">Sent messages.</TabList.Panel>
    </TabList>
  ),
};

With Panels Container

Activity content.
export const WithPanelsContainer: Story = {
  args: {
    defaultValue: 'tab2',
  },
  render: (args) => (
    <TabList {...args}>
      <TabList.Tab value="tab1">Summary</TabList.Tab>
      <TabList.Tab value="tab2">Activity</TabList.Tab>
      <TabList.Panels className="bg-wave-card">
        <TabList.Panel value="tab1">Summary content.</TabList.Panel>
        <TabList.Panel value="tab2">Activity content.</TabList.Panel>
      </TabList.Panels>
    </TabList>
  ),
};

Appearances

export const Appearances: Story = {
  render: (args) => (
    <div className="flex flex-col gap-4">
      {(['transparent', 'subtle', 'subtle-circular', 'filled-circular'] as const).map(
        (appearance) => (
          <TabList key={appearance} {...args} appearance={appearance} aria-label={appearance}>
            <TabList.Tab value="one">One</TabList.Tab>
            <TabList.Tab value="two">Two</TabList.Tab>
            <TabList.Tab value="three">Three</TabList.Tab>
          </TabList>
        ),
      )}
    </div>
  ),
};

Sizes

export const Sizes: Story = {
  render: (args) => (
    <div className="flex flex-col gap-4">
      {(['small', 'medium', 'large'] as const).map((size) => (
        <TabList key={size} {...args} size={size} aria-label={size}>
          <TabList.Tab value="one">One</TabList.Tab>
          <TabList.Tab value="two">Two</TabList.Tab>
        </TabList>
      ))}
    </div>
  ),
};

Icon Only

export const IconOnly: Story = {
  render: (args) => (
    <TabList {...args} aria-label="Views">
      <TabList.Tab value="people" icon={<TabGlyph />} aria-label="People" />
      <TabList.Tab value="teams" icon={<TabGlyph />} aria-label="Teams" />
      <TabList.Tab value="all" icon={<TabGlyph />}>
        All
      </TabList.Tab>
    </TabList>
  ),
};

Motion

export const Motion: Story = {
  render: ({ 'aria-label': _label, ...args }) => (
    <div className="flex flex-col gap-6">
      {motionCases(slowSlide).map(({ label, motion }) => (
        // The story renders one tab list per case; every other arg is forwarded.
        <TabList key={label} {...args} aria-label={label} motion={motion}>
          <TabList.Tab value="overview">Overview</TabList.Tab>
          <TabList.Tab value="activity">Recent activity</TabList.Tab>
          <TabList.Tab value="settings">Settings</TabList.Tab>
        </TabList>
      ))}
    </div>
  ),
};

Disabled

Content for Tab 2
export const Disabled: Story = {
  args: {
    disabled: true,
    defaultValue: 'tab2',
  },
  render: (args) => (
    <TabList {...args}>
      <TabList.Tab value="tab1">Tab 1</TabList.Tab>
      <TabList.Tab value="tab2">Tab 2</TabList.Tab>
      <TabList.Tab value="tab3">Tab 3</TabList.Tab>
      <TabList.Panel value="tab1">Content for Tab 1</TabList.Panel>
      <TabList.Panel value="tab2">Content for Tab 2</TabList.Panel>
      <TabList.Panel value="tab3">Content for Tab 3</TabList.Panel>
    </TabList>
  ),
};

Props

NameTypeRequiredDefaultDescription
valuestringNo

Controlled value of the selected tab ('': no tab selected). A controlled value that becomes undefined also selects no tab: the TabList stays controlled.

defaultValuestringNo

Selected tab for uncontrolled usage. When it is omitted (or ''), the first enabled tab written in the TabList's children is selected, from the first render (and in server-rendered HTML) on. Tabs written directly in the children, in Fragments or in wrapper elements that pass them as children (such as a Tooltip) count; a tab rendered by a custom component that renders TabList.Tab itself does not, even when it comes first in the DOM, so that server and client pick the same tab. When every tab comes from such a component, the first enabled tab in the DOM is selected once the tabs mount. To select a tab that a custom component renders, pass defaultValue.

onValueChange(value: string) => voidNo

Called with the new value when the selected tab changes (not when it is activated again).

orientation'horizontal' | 'vertical'No'horizontal'

Layout and arrow-key axis: 'horizontal' (Left/Right, mirrored in RTL) or 'vertical' (Up/Down).

appearance'transparent' | 'subtle' | 'subtle-circular' | 'filled-circular'No'transparent'

Look of the tabs: transparent underlines the selected tab, subtle and subtle-circular fill it with a subtle color (square or fully rounded), filled-circular fills it with the primary color. In forced colors the selected tab keeps a Highlight outline (or underline) in every appearance.

size'small' | 'medium' | 'large'No'medium'

Size of the tabs: their padding and type (medium is 14px text on 16 by 8px padding).

disabledbooleanNofalse

Disables the whole list (Fluent UI's TabList disabled): every tab is disabled, so none can be focused or selected, and the tablist reports aria-disabled="true" and a boolean data-disabled. The selected tab keeps its selected look and its panel stays shown: a controlled value or defaultValue still selects, and without either the first tab does. A tab's own disabled adds to it.

selectTabOnFocusbooleanNotrue

Whether moving focus with the arrow keys, Home and End also selects the tab (automatic activation, as in 0.5). With false, the keys only move focus and Enter, Space or a click selects the focused tab (manual activation, for panels that are slow to show). Fluent's default is false.

motionMotionSlot | nullNothe slide described above

Replaces the slide of the selected tab's line in the transparent appearance (the other appearances have no line and do not move): by default, when the selection moves, the line slides and stretches from the tab selected before to the new one, over the slow duration (300 ms) with the max decelerating curve. The classes go on the selected tab and time its line, the tab's after pseudo-element (write them with the after variant, and a reduced-motion counterpart); the line starts from the previous tab through two custom properties the TabList writes for one frame. null turns the slide off (the line moves at once); a class string or { className } replaces the classes with plain transition classes for the line, as above (it has no presence phases). A WaveProvider with motion="none" turns the default off, and a value here still applies under it. The line also moves at once while the user prefers reduced motion. Fluent's TabList slides its indicator with no prop to turn it off: this prop is a WaveUI addition.

refReact.Ref<HTMLDivElement>No

Ref to the role="tablist" element.

Any other prop is passed to the element it renders (HTMLDivElement).

Parts

  • TabList.Tab
  • TabList.Panel
  • TabList.Panels

Stable class names

PartClass
rootwave-tab-list