Skip to content
OAIT Design System

Design system / Components

Tabs

Underline tabs switch between views of the same thing without leaving the page; link tabs, drawn the same way, move between pages that share one place.

When to use

  • Views or panels of one object or page: Global ID's vault ("Passwords", "Codes", "Notes"), the Games role preview, the Tamakkan dashboard ("Results", "Messages"), and its sign-in screen ("Sign in", "Create account") (D-CSN-16).
  • Link tabs (--nav) when each tab has its own address: Global ID's person record keeps the tab in the URL (?tab=roles), so a reload or a shared link opens the same tab (canonical §10.17).

When not to use

  • Setting a mode of the same content (card side, scan direction): a segmented button. Anything that swaps panels is tabs; anything that only sets a value is a segmented button (D-CAI-16).
  • The product's top-level places: the navigation bar, rail or drawer.
  • Steps that must be done in order: the stepper.
  • Answers in a form: choice cards or radios.
  • One panel shown at a time inside a long page: an accordion.

Anatomy

  1. Container (.oa-tabs): the list, then the panel 24px below it.
  2. Tab list (__list): role="tablist" with an [aria-label]; a row on a 1px --color-outline-variant bottom edge that scrolls sideways when the tabs do not fit.
  3. Tab (__tab): a <button type="button" role="tab">, 48px tall, 16px inline padding, label-md, never wrapping.
  4. Icon (optional, __icon): 20px, 8px before the label; filled on the selected tab.
  5. Indicator: a 3px primary-ink bar under the selected tab, inset 12px from both ends, its top corners rounded 3px (the tab's ::after).
  6. Panel (__panel): role="tabpanel", labeled by its tab.

Link tabs (.oa-tabs--nav): a <nav aria-label> holding a ul.oa-tabs__list of <a class="oa-tabs__tab"> links; the current one has [aria-current="page"]; there is no panel element.

Variants

Variant Use for Key tokens
Underline tabs Panels of one page, switched in place --color-primary-ink (selected text and indicator), --color-on-surface-variant (rest), --color-outline-variant (list edge)
With icons Tabs whose icon helps tell them apart (the Games role preview) --size-icon-md, --space-2
Link tabs (--nav) Tabs with their own address the same, selected through [aria-current="page"]

Sizes

Size Height Padding Type style Icon size
Tab at least 48px (--size-touch-target) 0 16px (--space-4) label-md (14/20 600) 20px (--size-icon-md), 8px gap
Indicator 3px inset 12px (--space-3) at each end — —
Panel content 24px below the list (--space-stack-loose) content's own —

Tokens

Part Property Token
List bottom edge 1px --color-outline-variant (border-b border-outline-variant)
Tab rest text --color-on-surface-variant
Tab selected text --color-primary-ink (text-primary-ink)
Tab type --text-label-md and its companions
Tab height, padding --size-touch-target, --space-4
Indicator color, inset --color-primary-ink, --space-3
Indicator fade in --duration-short-4, --ease-standard
Tab state layer currentColor at --opacity-state-hover, --opacity-state-pressed; fade --duration-short-3
Tab focus ring --size-focus-ring, --color-focus-ring, offset --size-focus-inset
Panel gap above --space-stack-loose

States

State What changes
Rest Label on-surface-variant, no indicator.
Hover An 8% layer of the label color over the whole tab (--opacity-state-hover), only under (hover: hover); the selected primary-ink label keeps 5.99:1 light and 9.38:1 dark on surface under it (at least 4.70:1 and 4.53:1 on any surface).
Pressed A 12% layer (--opacity-state-pressed), at once.
Focus-visible The 3px ring drawn inside the tab (outline-offset: var(--size-focus-inset)), because the scrolling list clips (D-SEM-11).
Selected ([aria-selected="true"], or [aria-current="page"] on link tabs) Label and icon primary-ink, the icon filled, the 3px indicator. The bar is the non-color cue.
Disabled None: a tab that cannot open is left out.

Behavior

  • Automatic activation (APG tabs). The arrow keys move focus to the next or previous tab and select it at once; Home and End go to the first and last; the list wraps around. Only the selected tab is in the Tab order ([tabindex="0"], the rest -1); Tab moves on into the panel (D-CSN-16).
  • Right to left. In Arabic ArrowLeft goes forward and ArrowRight back, as the tabs run right to left.
  • Selected in view. Selecting a tab scrolls it into view inside the list (scrollIntoView({ block: 'nearest', inline: 'nearest' })); the list scrolls sideways (overflow-x: auto) and never wraps.
  • Panel. One panel shows the selected tab's content; give it [tabindex="0"] when it starts without a focusable element, so the keyboard reaches its text.
  • Link tabs. Plain links in the Tab order, no arrow keys; the page that opens marks its tab [aria-current="page"] and keeps the URL (?tab=roles), so a reload keeps the tab.
  • Motion. The indicator fades in over --duration-short-4 --ease-standard, the label color over --duration-short-3; nothing slides or scales; under reduced motion both change at once (canonical §7.3).

Script contract (underline tabs), on keydown in the list:

const tabs = [...list.querySelectorAll('[role="tab"]')];
const i = tabs.indexOf(document.activeElement);
const rtl = getComputedStyle(list).direction === 'rtl';
const step = { ArrowRight: rtl ? -1 : 1, ArrowLeft: rtl ? 1 : -1 }[event.key];
const j = step !== undefined ? (i + step + tabs.length) % tabs.length
  : event.key === 'Home' ? 0 : event.key === 'End' ? tabs.length - 1 : -1;
if (i < 0 || j < 0) return;
event.preventDefault();
select(tabs[j]); // aria-selected and tabindex on every tab, the panel's content and aria-labelledby, focus(), scrollIntoView()

Accessibility

  • role="tablist" with an [aria-label] ("Kinds of items"); each tab role="tab", [aria-selected], an id, and [aria-controls] pointing at the panel while it is shown; the panel role="tabpanel" with [aria-labelledby] its tab (canonical §10.17).
  • Link tabs: <nav aria-label="Person record"> of links; the current one [aria-current="page"]; no tab roles.
  • A tab's name is its visible label; icons are [aria-hidden="true"].
  • Targets: 48px tall, at least the label plus 32px wide (D-LAY-12).
  • Contrast: selected primary-ink on surface 6.79:1 light and 10.85:1 dark; rest on-surface-variant 8.88:1 and 10.87:1; the 3px indicator is the same primary-ink.
  • Forced colors: the indicator is drawn in Highlight, so the selected tab still shows.
  • Reduced motion: the indicator appears at once.

RTL and languages

  • The list follows the direction: in Arabic the first tab sits at the right; the arrow keys reverse; the indicator's inset is symmetric (D-BCP-30).
  • Icons do not mirror unless they are in the directional registry (canonical §8.3).
  • French labels run up to 32% longer (canonical §3.7): tabs never wrap or truncate, the list scrolls ("Rôles et affiliations", "Journal d’audit") (D-TYP-15).
  • Arabic labels take the taller Arabic line height inside the same 48px tab.

Content

Rule English Arabic French
A short noun per view, 1–3 words, sentence case Passwords · Codes · Notes كلمات المرور · الرموز · الملاحظات Mots de passe · Codes · Notes
The list's name says what the tabs sort Kinds of items أنواع العناصر Types d’éléments
Link tabs name the record's sections Overview · Roles and affiliations · Security · Audit log نظرة عامة · الأدوار والانتماءات · الأمان · سجل التدقيق Aperçu · Rôles et affiliations · Sécurité · Journal d’audit
  • Write "and", never "&" ("Roles and affiliations") (canonical §12.2). No verbs, no counts in a label, no Title Case.

Do and don't

Do Don't
Use tabs to swap panels of one page. Use tabs to set a value; that is a segmented button.
Let the list scroll sideways and keep the selected tab in view. Wrap or truncate tab labels.
Make tabs that change the address a nav of links. Put role="tab" on links that load a new page.
Draw the ring inside the tab. Let the scrolling list cut the ring.
Keep one tab selected at all times. Show a tab list with nothing selected.

Code

HTML (reference CSS)

Underline tabs:

<div class="oa-tabs">
  <div class="oa-tabs__list" role="tablist" aria-label="Kinds of items">
    <button class="oa-tabs__tab" type="button" role="tab" id="an-tb-passwords" aria-selected="true" aria-controls="an-tb-panel" tabindex="0">Passwords</button>
    <button class="oa-tabs__tab" type="button" role="tab" id="an-tb-codes" aria-selected="false" tabindex="-1">Codes</button>
    <button class="oa-tabs__tab" type="button" role="tab" id="an-tb-notes" aria-selected="false" tabindex="-1">Notes</button>
  </div>
  <div class="oa-tabs__panel" role="tabpanel" id="an-tb-panel" aria-labelledby="an-tb-passwords" tabindex="0">
    <p class="oa-text-body-lg">You have no passwords here yet.</p>
  </div>
</div>

With icons:

<div class="oa-tabs">
  <div class="oa-tabs__list" role="tablist" aria-label="Role preview">
    <button class="oa-tabs__tab" type="button" role="tab" id="an-tbi-participants" aria-selected="true" aria-controls="an-tbi-panel" tabindex="0"><span class="oa-icon oa-icon--md oa-tabs__icon" aria-hidden="true" translate="no">badge</span>Participants</button>
    <button class="oa-tabs__tab" type="button" role="tab" id="an-tbi-booths" aria-selected="false" tabindex="-1"><span class="oa-icon oa-icon--md oa-tabs__icon" aria-hidden="true" translate="no">storefront</span>Booth teams</button>
    <button class="oa-tabs__tab" type="button" role="tab" id="an-tbi-organizers" aria-selected="false" tabindex="-1"><span class="oa-icon oa-icon--md oa-tabs__icon" aria-hidden="true" translate="no">manage_accounts</span>Organizers</button>
    <button class="oa-tabs__tab" type="button" role="tab" id="an-tbi-hosts" aria-selected="false" tabindex="-1"><span class="oa-icon oa-icon--md oa-tabs__icon" aria-hidden="true" translate="no">mic</span>Hosts</button>
    <button class="oa-tabs__tab" type="button" role="tab" id="an-tbi-audience" aria-selected="false" tabindex="-1"><span class="oa-icon oa-icon--md oa-tabs__icon" aria-hidden="true" translate="no">tv</span>The audience</button>
  </div>
  <div class="oa-tabs__panel" role="tabpanel" id="an-tbi-panel" aria-labelledby="an-tbi-participants" tabindex="0">
    <p class="oa-text-body-lg">Your passport to getting involved.</p>
  </div>
</div>

Link tabs:

<nav class="oa-tabs oa-tabs--nav" aria-label="Person record">
  <ul class="oa-tabs__list">
    <li><a class="oa-tabs__tab" href="#an-tbn-overview" aria-current="page">Overview</a></li>
    <li><a class="oa-tabs__tab" href="#an-tbn-roles">Roles and affiliations</a></li>
    <li><a class="oa-tabs__tab" href="#an-tbn-security">Security</a></li>
    <li><a class="oa-tabs__tab" href="#an-tbn-audit">Audit log</a></li>
  </ul>
</nav>

Arabic:

<div dir="rtl" lang="ar">
  <div class="oa-tabs">
    <div class="oa-tabs__list" role="tablist" aria-label="أنواع العناصر">
      <button class="oa-tabs__tab" type="button" role="tab" id="an-tba-passwords" aria-selected="true" aria-controls="an-tba-panel" tabindex="0">كلمات المرور</button>
      <button class="oa-tabs__tab" type="button" role="tab" id="an-tba-codes" aria-selected="false" tabindex="-1">الرموز</button>
      <button class="oa-tabs__tab" type="button" role="tab" id="an-tba-notes" aria-selected="false" tabindex="-1">الملاحظات</button>
    </div>
    <div class="oa-tabs__panel" role="tabpanel" id="an-tba-panel" aria-labelledby="an-tba-passwords" tabindex="0">
      <p class="oa-text-body-lg">لا توجد كلمات مرور هنا بعد.</p>
    </div>
  </div>
</div>

Tailwind CSS v4

<div class="flex flex-col gap-stack-loose">
  <div role="tablist" aria-label="Kinds of items" class="flex overflow-x-auto border-b border-outline-variant">
    <button type="button" role="tab" id="tab-passwords" aria-selected="true" aria-controls="panel" tabindex="0" class="relative isolate inline-flex min-h-12 shrink-0 items-center gap-2 border border-transparent px-4 text-label-md whitespace-nowrap text-on-surface-variant transition-colors duration-short-3 before:absolute before:-inset-px before:-z-1 before:bg-current before:opacity-0 before:transition-opacity before:duration-short-3 after:absolute after:inset-x-3 after:-bottom-px after:h-[3px] after:rounded-t-[3px] after:transition-colors after:duration-short-4 hover:before:opacity-8 focus-visible:-outline-offset-4 active:before:opacity-12 active:before:duration-0 aria-selected:text-primary-ink aria-selected:after:bg-primary-ink">Passwords</button>
    <!-- every tab takes the same classes -->
    <button type="button" role="tab" id="tab-codes" aria-selected="false" tabindex="-1">Codes</button>
  </div>
  <div role="tabpanel" id="panel" aria-labelledby="tab-passwords" tabindex="0">…</div>
</div>
<!-- Link tabs: <nav aria-label="Person record"><ul class="flex overflow-x-auto border-b border-outline-variant"> of <a> with the same
     classes, aria-current="page" on the current one, selected through aria-[current=page]:text-primary-ink aria-[current=page]:after:bg-primary-ink. -->

React

Prop (Tabs) Type Default Description
label string — The tab list's accessible name
tabs { value: string; label: string; icon?: string }[] — The tabs, in order
value string — The selected tab; an unknown value selects the first
onValueChange (value: string) => void — Called on click and on every arrow, Home, and End key
children ReactNode — The selected tab's panel
Prop (LinkTabs) Type Default Description
label string — The nav's accessible name
tabs { href: string; label: string; current: boolean }[] — One link per tab; current renders [aria-current="page"]
<Tabs label={t('vault.open.tabs')} value={tab} onValueChange={setTab}
  tabs={[
    { value: 'passwords', label: t('vault.open.passwords') },
    { value: 'codes', label: t('vault.open.codes') },
    { value: 'notes', label: t('vault.open.notes') },
  ]}>
  {panel}
</Tabs>