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
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
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
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
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
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
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
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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
value | string | No | Controlled value of the selected tab ( | |
defaultValue | string | No | Selected tab for uncontrolled usage. When it is omitted (or | |
onValueChange | (value: string) => void | No | 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: |
appearance | 'transparent' | 'subtle' | 'subtle-circular' | 'filled-circular' | No | 'transparent' | Look of the tabs: |
size | 'small' | 'medium' | 'large' | No | 'medium' | Size of the tabs: their padding and type ( |
disabled | boolean | No | false | Disables the whole list (Fluent UI's |
selectTabOnFocus | boolean | No | true | Whether moving focus with the arrow keys, Home and End also selects the tab (automatic activation, as in 0.5). With |
motion | MotionSlot | null | No | the slide described above | Replaces the slide of the selected tab's line in the |
ref | React.Ref<HTMLDivElement> | No | Ref to the |
Any other prop is passed to the element it renders (HTMLDivElement).
Parts
TabList.TabTabList.PanelTabList.Panels
Stable class names
| Part | Class |
|---|---|
root | wave-tab-list |