useTabList

Provides the behavior and accessibility implementation for a tab list. Tabs organize content into multiple sections and allow users to navigate between them.

Arma virumque cano, Troiae qui primus ab oris.
Example
Tabs.tsx
Tabs.css
import {Tab, Tabs} from './Tabs';

<Tabs aria-label="History of Ancient Rome">
  <Tab id="FoR" title="Founding of Rome">Arma virumque cano, Troiae qui primus ab oris.</Tab>
  <Tab id="MaR" title="Monarchy and Republic">Senatus Populusque Romanus.</Tab>
  <Tab id="Emp" title="Empire">Alea jacta est.</Tab>
</Tabs>

API

Shows a tabs component with labels for each tab, a selection state, and the tab panel.Section 1Section 2TabTab (selected)Tab listTab panel
<Tabs>
  <TabList>
    <Tab>
      <SelectionIndicator />
    </Tab>
  </TabList>
  <TabPanels>
    <TabPanel />
  </TabPanels>
</Tabs>
useTabListState<T extends object>(props: <T>): <T>useTabList<T>( props: <T>, state: <T>, ref: <HTMLElementnull> ): useTab<T>( props: , state: <T>, ref: <FocusableElementnull> ): useTabPanel<T>( props: , state: <T>null, ref: <Elementnull> ):

TabListState

Properties

NameType
isDisabledboolean

Whether the tab list is disabled.

selectedItem<T>null

The value of the currently selected item.

collection<<T>>

A collection of items in the list.

selectionManager

A selection manager to read and update multiple selection state.

selectedKeyKeynull

The key for the currently selected item.

disabledKeysSet<Key>

A set of items that are disabled.

Methods

setSelectedKey(key: Keynull): void
Sets the selected key.

AriaTabListOptions

NameTypeDefault
keyboardActivation'automatic''manual'Default: 'automatic'

Whether tabs are activated automatically on focus or manually.

orientationDefault: 'horizontal'

The orientation of the tabs.

isDisabledbooleanDefault:

Whether the TabList is disabled. Shows that a selection exists, but is not available in that circumstance.

itemsIterable<T>Default:

Item objects in the collection.

selectedKeyKeyDefault:

The currently selected key in the collection (controlled).

defaultSelectedKeyKeyDefault:

The initial selected keys in the collection (uncontrolled).

onSelectionChange(key: Key) => voidDefault:

Handler that is called when the selection changes.

disabledKeysIterable<Key>Default:

The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.

TabListAria

NameType
tabListPropsDOMAttributes

Props for the tablist container.

AriaTabProps

NameType
keyKey

The key of the tab.

isDisabledboolean

Whether the tab should be disabled.

shouldSelectOnPressUpboolean

Whether the tab selection should occur on press up instead of press down.

TabAria

NameType
tabPropsDOMAttributes

Props for the tab element.

isSelectedboolean

Whether the tab is currently selected.

isDisabledboolean

Whether the tab is disabled.

isPressedboolean

Whether the tab is currently in a pressed state.

AriaTabPanelProps

NameType
idKey

The unique id of the tab.

TabPanelAria

NameType
tabPanelPropsDOMAttributes

Props for the tab panel element.