Skip to content

Tabs

BetaNavigationOpen in the workshop

Switches between views of one object without leaving the page.

[data-xg-tabs] > .xg-tabs__list[role=tablist] > button.xg-tab[role=tab][aria-selected][aria-controls] (+ .xg-count) · .xg-tabs__panel[role=tabpanel]

Example and markup

Live, from xg-ui.css and xg-ui.js. Switch the brand and mode on the example itself, or for the whole site in the header.

Tabs

Live since Nov 3 in 4 markets. Daily budget $5,000, even pacing.

Markup
<div data-xg-tabs>
<div class="xg-tabs__list" role="tablist" aria-label="Campaign">
<button class="xg-tab" role="tab" id="t-ov" aria-controls="p-ov" aria-selected="true">Overview</button>
<button class="xg-tab" role="tab" id="t-tg" aria-controls="p-tg" aria-selected="false">Targeting</button>
<button class="xg-tab" role="tab" id="t-cr" aria-controls="p-cr" aria-selected="false">Creatives <span class="xg-count">12</span>
</button>
<button class="xg-tab" role="tab" id="t-lg" aria-controls="p-lg" aria-selected="false">Request logs</button>
<button class="xg-tab" role="tab" id="t-ex" aria-controls="p-ex" aria-selected="false" aria-disabled="true">Experiments</button>
</div>
<div class="xg-tabs__panel" role="tabpanel" id="p-ov" aria-labelledby="t-ov">
<p style="margin:0">Live since Nov 3 in 4 markets. Daily budget $5,000, even pacing.</p>
</div>
<div class="xg-tabs__panel" role="tabpanel" id="p-tg" aria-labelledby="t-tg" hidden>
<p style="margin:0">US, DE, UK · Desktop and CTV · Video only.</p>
</div>
<div class="xg-tabs__panel" role="tabpanel" id="p-cr" aria-labelledby="t-cr" hidden>
<p style="margin:0">12 creatives, 2 in review.</p>
</div>
<div class="xg-tabs__panel" role="tabpanel" id="p-lg" aria-labelledby="t-lg" hidden>
<p style="margin:0">Raw request and response logs, last 24 hours.</p>
</div>
<div class="xg-tabs__panel" role="tabpanel" id="p-ex" aria-labelledby="t-ex" hidden>
</div>
</div>

States

Hover, focus and pressed are forced here with .is-hover, .is-focus and .is-active so they can be seen side by side; in a product they come from :hover, :focus-visible and :active.

Tabs: every state
StateTab
Default
Hover
Focus
Selected
With count
Disabled

When to use it

Use it for

Overview / Targeting / Creatives / Logs of one campaign.

Not for

steps in a sequence (Stepper); filters (Segmented control); top-level navigation.

Rules

  • Two to seven tabs, one or two words each.
  • The first tab is the overview and is selected by default; the selection survives a reload (put it in the URL).

Accessibility

  • Full WAI-ARIA tabs pattern: arrow keys move between tabs, Home/End jump, only the selected tab is in the tab order.

Every color pair this component uses is measured for both brands in light and dark on the Accessibility page.

Also in Navigation: Sidebar navigation, Topbar, Breadcrumb, Wizard steps, Dropdown menu.

Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).