Skip to content

Signal

Components

Tab strip

App views as a segmented control: .ct-tab-strip and .ct-segmented.ct-tabs.

The app's views as one Segmented control in a .ct-tab-strip. Set --count to the number of tabs and mark the current one aria-current="page". When a page has two sets of views (the app's and the admin's), put both in the strip and hide the one not in use.

Live example

The real classes from /site/chitransit.css in frames at phone, tablet and desktop widths, in the docs theme. The contract below shows each width in light and dark.

Phone · 390 × 760
Tablet · 768 × 900
Desktop · 1280 × 800

Code

<div class="ct-tab-strip">
  <nav class="ct-segmented ct-segmented--fill ct-tabs" aria-label="App views" style="--count:5">
    <button type="button">Search</button>
    <button type="button" aria-current="page">Stations</button>
    <button type="button">Routes</button>
    <button type="button">Map</button>
    <button type="button">Alerts</button>
  </nav>
</div>

Responsive behavior

ViewportLayout
> 900 wideEach tab at least 88 wide (size.tabMinimumWidth).
≤ 900 wide or ≤ 500 tall48 tall; tabs share the strip at least 56 wide and 44 tall, and the strip scrolls sideways, snapping, only when their labels can't fit.

Tokens

From tokens/components.tokens.json. Override one instance by setting the property without the ct- prefix.

Custom propertyValueAliasResolves to
--ct-tab-strip-gap-compactvar(--space-6){space.s6}6 pt
--ct-tab-strip-gapvar(--space-16){space.s16}16 pt
--ct-tab-strip-height-compactvar(--size-tab-strip-compact){size.tabStripCompact}48 pt
--ct-tab-strip-padding-compactvar(--space-2){space.s2}2 pt
--ct-tab-strip-padding-x-compactvar(--space-4){space.s4}4 pt
--ct-tab-strip-tab-min-height-compactvar(--size-minimum-tap-target){size.minimumTapTarget}44 pt
--ct-tab-strip-tab-min-width-compactvar(--size-tab-minimum-width-compact){size.tabMinimumWidthCompact}56 pt
--ct-tab-strip-tab-min-widthvar(--size-tab-minimum-width){size.tabMinimumWidth}88 pt
--ct-tab-strip-tab-padding-x-compactvar(--space-8){space.s8}8 pt

Variants

One form; no variants. .ct-tab-strip holds a <nav class="ct-segmented ct-segmented--fill ct-tabs"> with --count set; the current tab carries aria-current="page". The compact size follows the viewport. Nothing else exists.

<!-- Do -->
<div class="ct-tab-strip">
  <nav class="ct-segmented ct-segmented--fill ct-tabs" aria-label="App views" style="--count:3">
    <button type="button" aria-current="page">Stations</button>
    <button type="button">Routes</button>
    <button type="button">Map</button>
  </nav>
</div>
<!-- Don't: tab roles; the views are pages, not tab panels -->
<div class="ct-tab-strip" role="tablist">
  <button role="tab" aria-selected="true">Stations</button>
</div>

Usage

Do

  • Keep labels to one short word.
  • Show one tab set at a time.

Don't

  • Don't use more than five or six tabs.
  • Don't use the tab strip for filters; use a Filter or a Segmented control in the view.

Accessibility

  • A <nav> with a label holding buttons or links named by their text.
  • Compact tabs are at least 44pt tall.

Contract

Contract: components/tab-strip.yaml. States are drawn live by transit.js.