Tabs

Switches between related views.

When to use

Use tabs to switch between closely related views in the same page region. Use ordinary navigation links when each destination should load a separate page.

Default

JavaScript keeps only the active tab tabbable. Left/Right move; Home/End jumps to the first or last enabled tab.

Tab content 1

States and markup

The preview starts on the first tab and includes an unavailable third tab. Use native disabled on unavailable tab buttons. The following essential markup shows two enabled tabs; repeat the same unique button/panel relationship for additional views. Application code supplies switching and keyboard behavior.

HTML
<div class="tab-container">
	<div class="tabs" role="tablist" aria-label="Project views">
		<button
			class="tab is-active"
			id="overview-tab"
			type="button"
			role="tab"
			aria-controls="overview-panel"
			aria-selected="true"
			tabindex="0">
			Overview
		</button>
		<button
			class="tab"
			id="activity-tab"
			type="button"
			role="tab"
			aria-controls="activity-panel"
			aria-selected="false"
			tabindex="-1">
			Activity
		</button>
	</div>
	<div class="tab-contents">
		<div
			class="tab-content is-active"
			id="overview-panel"
			role="tabpanel"
			aria-labelledby="overview-tab"
			tabindex="0">
			Project summary
		</div>
		<div
			class="tab-content"
			id="activity-panel"
			role="tabpanel"
			aria-labelledby="activity-tab"
			tabindex="0"
			hidden>
			Recent activity
		</div>
	</div>
</div>

Accessibility and behavior

  • Give the tablist an accessible name. Each native tab button needs a unique id, role="tab", aria-controls and aria-selected; each panel needs role="tabpanel" and aria-labelledby.
  • Keep only the active enabled tab in the Tab order. Left/Right changes the active tab; Home/End moves to an edge. Disabled tabs are skipped. Tab moves into the active panel and onward.
  • Synchronize .is-active, aria-selected, tab stops and the panels’ hidden state. The Showcase provides this runtime; the published package contains styles.

CSS variables

Override these base defaults on the listed selector after the library styles. Variants and states may replace them; global tokens follow the active theme.

TokenDefaultPurposeScope / state
--tabs-bg-colortransparentBackground color..tabs
--tabs-border-widthvar(--border-width)Border thickness..tabs
--tabs-border-colorvar(--border-color)Border color..tabs
--tab-colorvar(--text-color)Tab label color..tab
--tab-bg-colortransparentTab background..tab
--tab-hover-colorvar(--action-color)Tab label color on hover..tab
--tab-hover-bg-colorvar(--bg-surface-hover)Tab background on hover..tab
--tab-active-colorvar(--action-color)Selected tab label color..tab
--tab-active-bg-colortransparentSelected tab background..tab
--tab-active-border-colorvar(--tab-active-color)Selected tab underline color..tab
--tab-border-width2pxBottom border thickness..tab
--tab-border-colortransparentUnselected tab underline color..tab
--tab-padding-yvar(--spacer-3)Top and bottom padding..tab
--tab-padding-xvar(--spacer-4)Left and right padding..tab
--tab-disabled-text-colorvar(--disabled-text-color)Text color while disabled..tab (disabled)
--tab-disabled-bg-colortransparentBackground color while disabled..tab (disabled)
--tab-disabled-border-colortransparentBorder color while disabled..tab (disabled)
--tab-focus-outline-widthvar(--focus-outline-width)Focus ring thickness..tab (focus)
--tab-focus-outline-stylevar(--focus-outline-style)Focus ring line style..tab (focus)
--tab-focus-outline-colorvar(--focus-outline-color)Focus ring color..tab (focus)
--tab-focus-outline-offsetcalc(-1 * var(--tab-focus-outline-width))Distance between the focus ring and control..tab (focus)
--tab-transition-durationvar(--transition-duration)Duration of visual state transitions..tab
--tab-transition-easingvar(--transition-easing)Timing curve for visual state transitions..tab
--tab-content-bg-colorvar(--bg-surface)Panel background..tab-content
--tab-content-paddingvar(--spacer-3)Panel spacing..tab-content
--tab-content-transition-durationvar(--transition-duration)Duration of panel opacity transitions..tab-content
--tab-content-transition-easingvar(--transition-easing)Timing curve of panel opacity transitions..tab-content