What the component guarantees
- The bar is a
role="tablist", each tab arole="tab"witharia-selected, and each rendered panel arole="tabpanel"labelled by its tab. - Only the active tab is in the tab order (roving
tabindex), so the bar is a single stop rather than one per tab. aria-controlsis set only when a panel is actually rendered, so it never points at a missing element.- Disabled tabs are skipped by the arrow keys.
- Each tab draws the 2px
--nb-c-focus-ringoutline under:focus-visible. - On a phone touch screen every tab is at least 44px tall and the
hit-areamixin makes a narrow tab 44px wide. The bar scrolls rather than wrapping. A desktop is unchanged. - Keyboard behaviour is tested in
tests/Tabs.test.ts, markup by axe intests/axe.test.ts.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves into the bar, landing on the active tab |
| ← → | Selects the previous or next tab, wrapping |
| Home | Selects the first tab |
| End | Selects the last tab |
Arrow keys select as they move (automatic activation), which the WAI-ARIA tabs pattern recommends when showing a panel is cheap.
What you own
- A name for the bar with
ariaLabelwhen a page carries more than one set of tabs. Two unnamed tablists sound identical. - Whether selection should follow focus. If showing a panel fires a request or discards unsaved input, automatic activation lets a held arrow key fire one per tab. Load the panel lazily, or keep that section out of a tab bar.
- Panels rendered elsewhere. Leave the slots out and only the bar renders, with no
aria-controls. Your router view is then the panel, and moving focus to its heading on change is yours (see After a route change).
Known gaps
- No manual screen reader pass has been recorded for this component.