Tabs
Primary and secondary tab rows with a sliding indicator, scrollable when they overflow.
import { Tabs, Tab } from '@windmorph/react';Keyboard
| Key | Action |
|---|---|
| Tab | Moves focus into the row, to the selected tab, and on into the panel. |
| Arrow Left or Arrow Right | Moves focus to the previous or next tab without selecting it. With keyboardActivation="automatic" it selects the tab too. |
| Home or End | Moves focus to the first or last tab. |
| Enter or Space | Selects the focused tab and shows its panel. |
The arrow keys wrap from the last tab to the first, stop on disabled tabs (disabledKeys) so screen reader users find them, though Enter, Space and a press don't select them, and are mirrored right to left, following the direction the row is laid out in.
Screen reader
- Role
- A
tablistoftabs, with the selected tab's content in atabpanel. - Accessible name
- The row is named by
aria-labeloraria-labelledby. Each tab is named by itstitle, or by its ownaria-labelwhen it is icon-only. - States announced
- Selected (
aria-selected) and disabled (aria-disabled). Each tab points at the panel witharia-controls, and the panel is labelled by its tab.
- Icons and the active indicator are hidden from assistive tech (
aria-hidden). - A
badgeis left out of the tab's name and describes it instead (aria-describedby), so "Inbox" is read with "12" as its description. A small dot badge reads "New notification", or itslabel. - A row with no panels (tabs that only navigate) renders no panel and leaves out
aria-controls.
Focus
- The row takes one Tab stop: focus lands on the selected tab, and the arrow keys move it between tabs (a roving tab index).
- Keyboard focus shows M3's focus indicator, a 3px
secondaryoutline drawn inside the tab, so neighbouring tabs and a scrolling row never clip it. Pointer presses show no ring. - The panel takes focus itself, with the same inset ring, only when it holds nothing focusable.
- In a scrollable row the selected tab scrolls to the centre.
Touch target
- Tabs with text, icons before labels, or icons only are at least 48px tall; tabs with icons above labels are at least 64px tall.
- Fixed tabs share the row's width; scrollable tabs are at least 90px wide.
- With
density(or the theme's), tabs lose 4px a step, to 36px (52px with icons above) at -3. They sit side by side in one row, so like dense menu items they keep full-height targets of their own, above WCAG 2.5.8's 24px minimum, rather than reaching outside the row. M3 asks not to apply density by default: offer it as the reader's choice.
Motion
Under reduced motion the indicator jumps to the selected tab instead of sliding, and a scrollable row scrolls to it at once. Colours still fade, and the press ripple appears at full size without growing.
What you need to do
- Name the row with
aria-labeloraria-labelledby. - Give an icon-only tab an
aria-labelthat says what it holds ("Video" rather than "Camera"). - Keep labels short and visible; a scrollable row lets them keep their natural width instead of truncating.
- Leave
swipeableoff when the panel holds its own swipeable content, such as a map or a carousel; the keys and presses still change tab.