Skip to main content
PimentCSS v1.0.1, what's new
Home

Tabs

Tablist, panels, and arrow-key navigation between tabs.

Styles live in scss/components/_tab.scss. Tabbed sections switch panels with keyboard support and WAI-ARIA tab semantics.

Anatomy

PartClassRole
Bar.tabsColumn stack: list + separator + panels
List.tabs__listFlex row of tab buttons (role="tablist")
Separator.tabs__separatorFull-width rule under the list
Item.tabrole="tab", bottom indicator when selected
Icon.tab__iconOptional 20px icon (aria-hidden)
Label.tab__labelVisible tab text
Panel.tab-panelrole="tabpanel", linked via aria-labelledby

Prerequisites

  • PimentCSS installed, Installation.
  • Icons, optional tab icons via ph() (Phosphor in this doc).
  • Typography, labels use body medium tokens (Typography).

Tab item states

Matrix previews are static buttons (no tablist roles) so they do not compete with live tablists. Doc-only .tab--hover and .tab--focus preview states; production uses :hover and :focus-visible. Selected pairs with .tab--selected or aria-selected="true".

Default
Focus
Hover
Disabled
Unselected
Selected

Tab bar (static)

Text-only tabs with one visible panel. The selected tab uses tabindex="0"; others use -1 until focus moves in a live bar.


Content for Details. Link panels with aria-controls and aria-labelledby.

Tab bar with icons

Icons are decorative; keep aria-hidden="true" on the icon element and put the name in .tab__label.


Content for Details. Link panels with aria-controls and aria-labelledby.

Interactive tab bar

Add data-tabs-live on .tabs and call wireAllTabs() after load. Arrow Left/Right (and Up/Down), Home, End, and click update selection and panels.


Overview: summary cards and recent activity.

Class reference

ClassDescription
.tabsTab bar container (column, full width)
.tabs__listHorizontal flex list of tabs
.tabs__separatorBorder-top rule under the list
.tabTab button: min-height 50px, bottom indicator
.tab--selectedSelected tab (semibold, action border)
.tab--hoverDoc-only hover preview
.tab--focusDoc-only focus ring preview
.tab--disabledDoc-only disabled preview (prefer disabled)
.tab__icon20px icon slot
.tab__labelTab label text
.tab-panelPanel content; use hidden when inactive

Customize (Sass)

  1. Tab sizing

    Override padding, list gap, indicator width, and min height before importing components.
    @use "pimentcss-design-system" with (
      $tab-item-px: 1rem,
      $tab-item-py: 0.75rem,
      $tab-list-gap: 0.75rem,
      $tab-min-height: 3.125rem,
      $tab-indicator-width: 0.25rem
    );
  2. Rebuild CSS

    Run after editing _tab.scss.
    npm run build:css

Accessibility (RGAA / WCAG)

Tablist pattern

  • Roles, role="tablist" on the list container, role="tab" on each tab, role="tabpanel" on each panel.
  • Selection, set aria-selected="true" on the active tab only; pair with .tab--selected for visuals.
  • Linkage, each tab needs a unique id, aria-controls pointing to its panel id, and panels use aria-labelledby back to the tab.
  • Roving tabindex, active tab tabindex="0", others -1; move focus with arrow keys in the live example.
  • Panels, hide inactive panels with the hidden attribute (and optionally aria-hidden="true" when wired).
  • Disabled, use the native disabled attribute on tab buttons.
  • Keyboard, Arrow Left/Right (and Up/Down), Home, End on the live tab bar; Enter/Space activate on click.
  • Focus, :focus-visible outline is built into .tab.

Next steps