Skip to main content
Kaleidoscope

Tabs

Display a panel of content in context based on selection from a list of tabs related to a singular concept.

Basic example

Tabs provides a set of composable tab components. Place a set of Tab components within a TabList and a set of corresponding TabPanel components within TabPanels.

Editable example

Best practices

  1. Avoid using tabs for disparate content. A set of tabs should relate to each other somehow and not be an unpredictably unrelated series of items.
  2. Use tabs to split long or overwhelming content into logically related chunks
  3. Use short single word labels
  4. Use between 2—8 tabs

Initial tab

By default, the first tab will initially be selected. If you need to specify another tab, use the initialIndex prop on Tabs.

Editable example

Alignment

Specify the horizontal alignment tabs within the TabList using the align prop. Choose an alignment that conforms to the alignment of other elements in the same context. For example, a page with a center aligned title and tabs underneath should center align the tabs.

Editable example

Bordered list

Use the isBordered prop on TabList to render a border between the list of tabs and the TabPanels.

If you're using the tabs within a panel or card, you'll also want to add some padding to the TabList and TabPanels. @space-s on the list and @space-m on the panels allows the Tab label to align with the panel content.

Editable example

Controlled

Tabs can be externally controlled using the selectedIndex and onChange props.

Editable example

Accessibility

  • Always provide an aria-label on the TabList component that describes what the set of tabs is for e.g. "Style options" for the tabs within the block styles popover.
  • Tabs automatically handles focus management and keyboard interactions. The TabList makes use of a roving tabindex, so only the selected tab is focused when tabbed to, and pressing the arrow keys moves between tabs.