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.
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.
<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-controlsandaria-selected; each panel needsrole="tabpanel"andaria-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’hiddenstate. 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.
| Token | Default | Purpose | Scope / state |
|---|---|---|---|
--tabs-bg-color | transparent | Background color. | .tabs |
--tabs-border-width | var(--border-width) | Border thickness. | .tabs |
--tabs-border-color | var(--border-color) | Border color. | .tabs |
--tab-color | var(--text-color) | Tab label color. | .tab |
--tab-bg-color | transparent | Tab background. | .tab |
--tab-hover-color | var(--action-color) | Tab label color on hover. | .tab |
--tab-hover-bg-color | var(--bg-surface-hover) | Tab background on hover. | .tab |
--tab-active-color | var(--action-color) | Selected tab label color. | .tab |
--tab-active-bg-color | transparent | Selected tab background. | .tab |
--tab-active-border-color | var(--tab-active-color) | Selected tab underline color. | .tab |
--tab-border-width | 2px | Bottom border thickness. | .tab |
--tab-border-color | transparent | Unselected tab underline color. | .tab |
--tab-padding-y | var(--spacer-3) | Top and bottom padding. | .tab |
--tab-padding-x | var(--spacer-4) | Left and right padding. | .tab |
--tab-disabled-text-color | var(--disabled-text-color) | Text color while disabled. | .tab (disabled) |
--tab-disabled-bg-color | transparent | Background color while disabled. | .tab (disabled) |
--tab-disabled-border-color | transparent | Border color while disabled. | .tab (disabled) |
--tab-focus-outline-width | var(--focus-outline-width) | Focus ring thickness. | .tab (focus) |
--tab-focus-outline-style | var(--focus-outline-style) | Focus ring line style. | .tab (focus) |
--tab-focus-outline-color | var(--focus-outline-color) | Focus ring color. | .tab (focus) |
--tab-focus-outline-offset | calc(-1 * var(--tab-focus-outline-width)) | Distance between the focus ring and control. | .tab (focus) |
--tab-transition-duration | var(--transition-duration) | Duration of visual state transitions. | .tab |
--tab-transition-easing | var(--transition-easing) | Timing curve for visual state transitions. | .tab |
--tab-content-bg-color | var(--bg-surface) | Panel background. | .tab-content |
--tab-content-padding | var(--spacer-3) | Panel spacing. | .tab-content |
--tab-content-transition-duration | var(--transition-duration) | Duration of panel opacity transitions. | .tab-content |
--tab-content-transition-easing | var(--transition-easing) | Timing curve of panel opacity transitions. | .tab-content |