Skip to content

Tabs

A wrapper around React Aria’s Tabs, TabList, Tab, and TabPanel components. Manages ARIA tab/tabpanel relationship and keyboard navigation automatically.

Terminal window
npx @a2ra/cli add tabs
{
"type": "Tabs",
"props": {
"tabs": [
{ "id": "overview", "label": "Overview" },
{ "id": "activity", "label": "Activity" },
{ "id": "settings", "label": "Settings" }
],
"defaultSelectedKey": "overview"
},
"children": [
{ "type": "Text", "children": "Overview content here." },
{ "type": "Text", "children": "Activity feed here." },
{ "type": "Text", "children": "Settings panel here." }
]
}
PropTypeDescription
tabsTabItem[]Tab definitions (see below)
defaultSelectedKeystringUncontrolled initially selected tab ID
selectedKeystringControlled selected tab ID
disabledKeysstring[]IDs of non-interactive tabs
orientationhorizontal default
vertical
Tab list direction
keyboardActivationautomatic default
manual
Whether arrow keys also activate tabs
ariaLabelstringARIA label for the tab list
childrennode[]Content panels, matched to tab IDs in order
FieldTypeDescription
idstringUnique tab identifier
labelstringVisible tab text
isDisabledbooleanDisables this tab
  • children are matched to tabs by position. The first child is the panel for the first tab, etc.
  • keyboardActivation: "manual" requires pressing Enter or Space to activate a focused tab. Use this when switching tabs triggers a data fetch to avoid unnecessary requests.
  • The tab list has role="tablist" and each panel has role="tabpanel" with aria-labelledby pointing to its tab, all managed by React Aria.