Tabs
The TabList component is used for navigating frequently accesssed, but distinct categories.
Accessibility
tab
,shift + tab
- to move focus between tabs.Space
orEnter
- to display the selected tab's contentaria-selected
,aria-disabled
are applied to the tabs.- Roles:
role=tab
,role=tablist
,role=tabpanel
Examples
tabId
is mandatory forTabsPanel
when used within StatefulTabs.- We do not assume where
TabList
orTabsPanels
would lie inside StatefulTabs. - If
tabId
is not supplied toTab
insideTabList
then it is their ordered index.
tabId
supplied toTab
insideTabList
corresponds to thetabId
to be passed to correspondingTabsPanel
.
API
TabList props
Name | Type | Default | Description |
---|---|---|---|
activateOnFocus | boolean | false | Indicates 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