Tabs

A row of tabs and one visible panel. Keyboard and screen readers work out of the box.

Edit page

Example

Billed every month. Cancel at any time.

Example.jsx
import { Tabs } from './components/Tabs'

<Tabs
  label='Plans'
  items={[
    { label: 'Monthly', content: <p>Billed every month.</p> },
    { label: 'Yearly', content: <p>Two months free.</p> },
  ]}
/>

Keyboard

Tab moves into the list and on to the panel. Left and right arrows move between tabs, Home and End jump to the first and the last. Only the active tab is in the tab order.

Parts

ClassWhat it is
tabsthe wrapper
tabs-listthe row of buttons, role tablist
tabs-panelone panel, role tabpanel, hidden unless active

The active button is styled by aria-selected, not by a class.

Variables

VariableDefaultWhat it sets
$tabs-gap4pxspace between tabs
$tabs-padding4pxpadding of the list
$tabs-height32pxheight of a tab
$tabs-radius$radiusradius of the list
$tabs-backgroundvar(--surface)background of the list
$tabs-activevar(--page)background of the active tab
$tabs-shadow0 1px 2px rgba($dark, .08)shadow of the active tab