Tabs
A segmented control for switching between views.
| Name | Type | What it does |
|---|---|---|
tabs | component | The track |
tab | part | One segment, on a <button> or <a> |
aria-selected="true" | state | Marks the current tab (aria-current on links) |
aria-controls="panel-id" | part | With behaviors.js loaded: the id of the panel this tab shows. Give every panel but the first the hidden attribute |
Switching panels needs behaviors.js (or the React component). It also adds the keyboard support people expect: one tab stop for the set, arrow keys to move, Home and End to jump.
Tabs that switch panels
Twelve albums, 4,580 photos.
Mika added 36 photos to Tokyo.
Sharing is on for this project.
<div style="display: grid; gap: 1rem; justify-items: start">
<div class="tabs" role="tablist" aria-label="Project">
<button class="tab" role="tab" aria-selected="true" aria-controls="panel-overview">Overview</button>
<button class="tab" role="tab" aria-controls="panel-activity">Activity</button>
<button class="tab" role="tab" aria-controls="panel-settings">Settings</button>
</div>
<p id="panel-overview" role="tabpanel">Twelve albums, 4,580 photos.</p>
<p id="panel-activity" role="tabpanel" hidden>Mika added 36 photos to Tokyo.</p>
<p id="panel-settings" role="tabpanel" hidden>Sharing is on for this project.</p>
</div>