Skip to content

Tabs

A row of tabs and the panel under it, underlined or segmented, on the markup of the ARIA tab pattern.

  • .aparte-tabs
On this page
Open

Two looks, one behaviour. --underline marks the current tab with a rule beneath it, the quieter of the two, for switching views; --segmented puts the row in a track and fills the current tab, which reads as a control. The artifact card’s Code and Preview are underlined tabs; this site’s theme switch is segmented.

The recipe draws the state; aria-selected says which tab is current, and your code sets it.

The markup of the tab pattern is the whole contract: one tab stop for the row (tabindex="0" on the selected tab, -1 on the others), aria-controls from each tab to its role="tabpanel", and aria-labelledby back. Moving between tabs with the arrow keys is your script’s; the artifact plugin’s card does it in a few lines.

It reads only the theme’s shared tokens, listed on the CSS variables reference.

.aparte-tabs · .aparte-tabs--segmented · .aparte-tabs--underline · .aparte-tabs__panel · .aparte-tabs__tab

  • Use role="tablist", role="tab" and role="tabpanel" with the attributes above, and the arrow keys between tabs: that is what a screen reader announces and expects.
  • Hide the panels that are not selected with hidden.