Tabs

The TabList component is used for navigating frequently accesssed, but distinct categories.

Accessibility

  • tab, shift + tab - to move focus between tabs.
  • Space or Enter - to display the selected tab's content
  • aria-selected, aria-disabled are applied to the tabs.
  • Roles: role=tab, role=tablist, role=tabpanel

Examples

Default Tabs

Currently No tasks assigned to Me

Default tabs with icons

Profile Page

Flap Tabs

Please write a new message

Custom TabIds Tabs

Success

Stateful Tabs

List of items to be approved
  • tabId is mandatory for TabsPanel when used within StatefulTabs.
  • We do not assume where TabList or TabsPanels would lie inside StatefulTabs.
  • If tabId is not supplied to Tab inside TabList then it is their ordered index.

Stateful Custom TabIds Tabs

Text in Green
  • tabId supplied to Tab inside TabList corresponds to the tabId to be passed to corresponding TabsPanel.

Icon Tabs

Search

Tabs with Tooltip

API

TabList props

NameTypeDefaultDescription
activateOnFocus
boolean
falseIndicates when focusing/navigating using arrow keys, tab should also be selected.
activeTabId
string
Key of the the tab to be selected.
children
react node
An array of Tab components.
className
string
Enriched style to be provided to TabList
onChange
function
Change handler that is called every time a new tab is selected.
overrides
custom
Lets you customize all aspects of the component.
position
'top'| 'left'| 'right'
The orientation of the tabs component.
variant
'default'| 'flap'
The variant of the tab component.

You can check the implementation of the component for more details.

Tabs exports

You can import this module like so:

import {StatefulTabs} from 'spaceweb/tabs'

It exports the following components or utility functions:

  • StatefulTabs
  • Tab
  • TabList
  • TabsPanel