Stable
Tabs switch between views of the same thing without leaving the screen: Due, Submitted and History readings, for example. The selected tab has an accent underline.
Tabs are buttons with role="tab" inside a role="tablist". Move between them with the arrow keys, and show only the selected panel.
Specifications
Anatomy
Anatomy
Size and spacing
Tabs
Two to five tabs. Put the most used view first and select it by default.
Example
States
Default
Hover
Focus
Selected
Example
States
Default
Hover
Focus
Selected
Usage
When to use
- Two to five views of the same thing.
When not to use
- Steps in a process: show one step per page.
- Going to a different part of the app: use links.
- More than five views: use a select.
Content
- One or two words per tab: "Due", "History".
- Do not put counts in every tab; add one only where it helps, such as "Due (3)".
Do and don't
Do
- Keep labels to one or two words.
Don't
- Nest tabs.
Implementation
HTML
<div class="at-tabs" role="tablist">
<button type="button" class="at-tab" role="tab" aria-selected="true">Due</button>
<button type="button" class="at-tab" role="tab" aria-selected="false">Submitted</button>
<button type="button" class="at-tab" role="tab" aria-selected="false">History</button>
</div>
<p>Due readings</p>Classes
| Class | What it does |
|---|---|
at-tabs | Tab row |
at-tab | One tab; aria-selected="true" marks the current one |
Tokens used
--at-border, --at-text-subtle, --at-text, --at-border-primary
Accessibility
- Use role="tablist" / "tab" / "tabpanel" and move with arrow keys.