Navigation

Tabs

<forma-tabs>

Focused views with keyboard and deep-link integration hooks plus mobile overflow strategy.

Authoring tag
<forma-tabs>
Category
Navigation
Behavior owner
Application / Limen
Canonical source
patterns/tabs.html

Purpose

Tabs switch between sibling views of one object, such as the Overview, History and Evidence of a record. Forma styles the ARIA tabs structure: a role="tablist" of button role="tab" elements and role="tabpanel" sections. The selected tab is drawn from aria-selected="true" with a surface change and an accent underline. Forma has no script, so the application (Limen) owns selection: updating aria-selected, showing the right panel with hidden, roving tabindex, arrow-key movement, manual or automatic activation, and deep-link sync with the URL.

Use when

  • One object has several peer views and the user looks at one at a time.
  • Views are independent enough that hiding the others does not lose context.
  • The current view should be addressable by URL (deep link).

Avoid when

  • The views are separate pages or destinations: use Navigation shell or links.
  • The content is a sequence the user must complete in order: use Wizard.
  • The control filters or changes a value rather than switching views: use Segmented control.
  • Several sections should be readable together: use Disclosure sections or plain headings.

Behavior to know

  • The tab list scrolls horizontally inside itself when tabs overflow; tabs never wrap or shrink.
  • Each tab is at least 44px tall.
  • Selection is shown by position cue (a 3px underline) and a surface change, not color alone.
  • The motion scope defaults to the light preset; the pattern states it explicitly with data-forma-motion-weight="light".

Basic example

The smallest correct markup: the canonical pattern from patterns/tabs.html inside its public tag. Copy this first, then adapt labels, names and state.

Canonical

Minimal tabs

Rendered from the canonical pattern file.

Static specimen. Its buttons stand for application actions that the consuming application implements; this script-free documentation does not perform them. Its controls are shown for their markup and appearance and cannot be operated here.

Overview

Current record summary and legal actions supplied by the application.

HTML · Minimal tabs Raw HTML for HTML · Minimal tabs
<forma-tabs class="forma-component-tag">
<section class="forma-tabs" data-forma-motion-weight="light">
  <div class="forma-tabs__list" role="tablist" aria-label="Record sections">
    <button type="button" role="tab" id="tab-overview" aria-selected="true" aria-controls="panel-overview">Overview</button>
    <button type="button" role="tab" id="tab-history" aria-selected="false" aria-controls="panel-history">History</button>
    <button type="button" role="tab" id="tab-evidence" aria-selected="false" aria-controls="panel-evidence">Evidence</button>
  </div>
  <section class="forma-tabs__panel" id="panel-overview" role="tabpanel" aria-labelledby="tab-overview">
    <h3>Overview</h3>
    <p>Current record summary and legal actions supplied by the application.</p>
  </section>
</section>
</forma-tabs>

Click or tap the code once to select all of it, then copy.

Examples

Scenario

Second tab selected with roving focus

History is selected. The application has applied roving tabindex (only the selected tab is in the tab order), hidden the other panels, and marked the visible panel with data-forma-motion-entry so it fades in when shown.

Static specimen. Its buttons stand for application actions that the consuming application implements; this script-free documentation does not perform them. Its controls are shown for their markup and appearance and cannot be operated here.

Invoice 1042

History

Sent 3 June, viewed 4 June, reminder sent 1 July.

HTML · Second tab selected with roving focus Raw HTML for HTML · Second tab selected with roving focus
<forma-tabs class="forma-component-tag">
  <section class="forma-tabs" data-forma-motion-weight="light" aria-labelledby="tabs-history-heading">
    <h2 id="tabs-history-heading">Invoice 1042</h2>
    <div class="forma-tabs__list" role="tablist" aria-label="Invoice sections">
      <button type="button" role="tab" id="tabs-history-tab-overview" aria-selected="false" aria-controls="tabs-history-panel-overview" tabindex="-1">Overview</button>
      <button type="button" role="tab" id="tabs-history-tab-history" aria-selected="true" aria-controls="tabs-history-panel-history">History</button>
      <button type="button" role="tab" id="tabs-history-tab-payments" aria-selected="false" aria-controls="tabs-history-panel-payments" tabindex="-1">Payments</button>
    </div>
    <section class="forma-tabs__panel" id="tabs-history-panel-overview" role="tabpanel" aria-labelledby="tabs-history-tab-overview" hidden>
      <h3>Overview</h3>
      <p>Issued 3 June to Northwind Ltd. Due 3 July.</p>
    </section>
    <section class="forma-tabs__panel" id="tabs-history-panel-history" role="tabpanel" aria-labelledby="tabs-history-tab-history" data-forma-motion-entry>
      <h3>History</h3>
      <p>Sent 3 June, viewed 4 June, reminder sent 1 July.</p>
    </section>
    <section class="forma-tabs__panel" id="tabs-history-panel-payments" role="tabpanel" aria-labelledby="tabs-history-tab-payments" hidden>
      <h3>Payments</h3>
      <p>No payments recorded.</p>
    </section>
  </section>
</forma-tabs>

Click or tap the code once to select all of it, then copy.

Scenario

Many tabs overflowing the list

Seven tabs in a narrow container. The list scrolls horizontally inside its own bounds with a thin scrollbar rather than wrapping; the page itself does not scroll sideways.

Static specimen. Its buttons stand for application actions that the consuming application implements; this script-free documentation does not perform them. Its controls are shown for their markup and appearance and cannot be operated here.

Checkout service, tier 1, healthy.

HTML · Many tabs overflowing the list Raw HTML for HTML · Many tabs overflowing the list
<forma-tabs class="forma-component-tag">
  <section class="forma-tabs" style="max-inline-size: 24rem;">
    <div class="forma-tabs__list" role="tablist" aria-label="Service details">
      <button type="button" role="tab" id="tabs-overflow-tab-summary" aria-selected="true" aria-controls="tabs-overflow-panel-summary">Summary</button>
      <button type="button" role="tab" id="tabs-overflow-tab-deployments" aria-selected="false" aria-controls="tabs-overflow-panel-deployments" tabindex="-1">Deployments</button>
      <button type="button" role="tab" id="tabs-overflow-tab-alerts" aria-selected="false" aria-controls="tabs-overflow-panel-alerts" tabindex="-1">Alerts</button>
      <button type="button" role="tab" id="tabs-overflow-tab-dependencies" aria-selected="false" aria-controls="tabs-overflow-panel-dependencies" tabindex="-1">Dependencies</button>
      <button type="button" role="tab" id="tabs-overflow-tab-owners" aria-selected="false" aria-controls="tabs-overflow-panel-owners" tabindex="-1">Owners</button>
      <button type="button" role="tab" id="tabs-overflow-tab-costs" aria-selected="false" aria-controls="tabs-overflow-panel-costs" tabindex="-1">Costs</button>
      <button type="button" role="tab" id="tabs-overflow-tab-audit" aria-selected="false" aria-controls="tabs-overflow-panel-audit" tabindex="-1">Audit log</button>
    </div>
    <section class="forma-tabs__panel" id="tabs-overflow-panel-summary" role="tabpanel" aria-labelledby="tabs-overflow-tab-summary"><p>Checkout service, tier 1, healthy.</p></section>
    <section class="forma-tabs__panel" id="tabs-overflow-panel-deployments" role="tabpanel" aria-labelledby="tabs-overflow-tab-deployments" hidden><p>Last deployed 2 hours ago.</p></section>
    <section class="forma-tabs__panel" id="tabs-overflow-panel-alerts" role="tabpanel" aria-labelledby="tabs-overflow-tab-alerts" hidden><p>No open alerts.</p></section>
    <section class="forma-tabs__panel" id="tabs-overflow-panel-dependencies" role="tabpanel" aria-labelledby="tabs-overflow-tab-dependencies" hidden><p>Depends on payments and inventory.</p></section>
    <section class="forma-tabs__panel" id="tabs-overflow-panel-owners" role="tabpanel" aria-labelledby="tabs-overflow-tab-owners" hidden><p>Owned by the Commerce team.</p></section>
    <section class="forma-tabs__panel" id="tabs-overflow-panel-costs" role="tabpanel" aria-labelledby="tabs-overflow-tab-costs" hidden><p>Within budget this month.</p></section>
    <section class="forma-tabs__panel" id="tabs-overflow-panel-audit" role="tabpanel" aria-labelledby="tabs-overflow-tab-audit" hidden><p>14 changes this week.</p></section>
  </section>
</forma-tabs>

Click or tap the code once to select all of it, then copy.

Mobile

Each mobile example renders in its own document inside a real narrow viewport, so Forma's media and container queries run exactly as they would on a phone. Choose a width to compare.

Mobile example

Tabs on a phone

Four tabs at phone width. The list becomes horizontally scrollable when the labels no longer fit; each tab keeps its full label and 44px height.

Static specimen. Its buttons stand for application actions that the consuming application implements; this script-free documentation does not perform them. Its controls are shown for their markup and appearance and cannot be operated here.

Viewport width

Frames narrower than the selected width show the component at the width available.

What changes at narrow widths

  • Tabs never wrap onto a second row; .forma-tabs__list scrolls horizontally inside its own bounds when they overflow.
  • Tabs keep their natural width (flex: 0 0 auto), so labels are never truncated or squeezed.
  • Each tab is at least 44px tall; swipe scrolls the list and a tap selects.
  • The application should scroll the selected tab into view on load and after keyboard navigation so it is not hidden off-edge.
HTML · Tabs on a phone Raw HTML for HTML · Tabs on a phone
<forma-tabs class="forma-component-tag">
  <section class="forma-tabs">
    <div class="forma-tabs__list" role="tablist" aria-label="Order sections">
      <button type="button" role="tab" id="tabs-mobile-tab-items" aria-selected="true" aria-controls="tabs-mobile-panel-items">Items</button>
      <button type="button" role="tab" id="tabs-mobile-tab-shipping" aria-selected="false" aria-controls="tabs-mobile-panel-shipping" tabindex="-1">Shipping</button>
      <button type="button" role="tab" id="tabs-mobile-tab-returns" aria-selected="false" aria-controls="tabs-mobile-panel-returns" tabindex="-1">Returns</button>
      <button type="button" role="tab" id="tabs-mobile-tab-messages" aria-selected="false" aria-controls="tabs-mobile-panel-messages" tabindex="-1">Customer messages</button>
    </div>
    <section class="forma-tabs__panel" id="tabs-mobile-panel-items" role="tabpanel" aria-labelledby="tabs-mobile-tab-items"><p>3 items, total 84.00.</p></section>
    <section class="forma-tabs__panel" id="tabs-mobile-panel-shipping" role="tabpanel" aria-labelledby="tabs-mobile-tab-shipping" hidden><p>Ships from the Leeds warehouse.</p></section>
    <section class="forma-tabs__panel" id="tabs-mobile-panel-returns" role="tabpanel" aria-labelledby="tabs-mobile-tab-returns" hidden><p>No returns requested.</p></section>
    <section class="forma-tabs__panel" id="tabs-mobile-panel-messages" role="tabpanel" aria-labelledby="tabs-mobile-tab-messages" hidden><p>No messages.</p></section>
  </section>
</forma-tabs>

Click or tap the code once to select all of it, then copy.

Baseline

Mobile · 320px

The canonical pattern in a true 320px viewport, the minimum width every Forma component must support without page-level horizontal scrolling.

Static specimen. Its buttons stand for application actions that the consuming application implements; this script-free documentation does not perform them. Its controls are shown for their markup and appearance and cannot be operated here.

Viewport width

Frames narrower than the selected width show the component at the width available.

API and configuration

Forma components have no JavaScript API. Their public contract is the markup: native elements and attributes you write, and the CSS hooks below. The CSS hook table is generated from the built stylesheet, so it always matches the shipped implementation.

Native and ARIA attributes
AttributeOnValuesDefaultDescription
rolelist, buttons, panelstablist | tab | tabpanel—Required ARIA tabs roles. Forma's selectors target [role="tab"] inside the list.
aria-selectedtabtrue | false—Set by the application. Forma draws the selected treatment from aria-selected="true".
aria-controlstabid of its panel—Links each tab to its panel. Every referenced panel must exist in the DOM.
aria-labelledbytabpanelid of its tab—Names the panel after its tab.
aria-labeltabliststring—Names the set of tabs.
tabindextab-1 on unselected tabs0 (native button)Roving tab stop written by the application so Tab enters the list once, at the selected tab.
hiddentabpanelbooleanabsentHides inactive panels. The application toggles it with selection.
typetabbutton—Prevents tabs inside a form from submitting it.
CSS hooks (derived from dist/all.css)
HookKindValues or defaultDescription
.forma-tabsBlock class—Root section and motion scope.
.forma-tabs__listElement class—The tablist: a flex row with a bottom rule that scrolls horizontally when tabs overflow.
.forma-tabs__panelElement class—A tab panel with vertical padding.
[data-forma-motion-entry]Attribute hook—Presence attribute on .forma-tabs__panel. When the panel is inserted or un-hidden it starts at zero opacity and 0.25rem lower, then settles into place.
[data-forma-motion-weight]Attribute hook"heavy", "light", "standard"Presentation-only perceived mass for the underline and tab settle: light (default here), standard or heavy. Never encodes importance.
Keyboard interaction
KeysResult
Tab / Shift+TabNative: moves focus to and from the tab list. With application roving tabindex, only the selected tab is a stop; then Tab moves into the panel.
Enter / SpaceNative button activation. The application selects the focused tab in response.
Left / Right Arrow, Home, EndNot native. The application must move focus between tabs and, for automatic activation, select on focus.
Events
EventDescription
clickNative click on a tab button; the application updates aria-selected, tabindex, hidden and the URL.

Form behavior

Does not participate in forms. Tabs are buttons with type="button" so they never submit.

States

Tabs states
StateHow it is expressedPresentation
Unselectedaria-selected="false"Transparent tab, nudged 0.08rem down, underline scaled to zero.
Selectedaria-selected="true"Secondary surface, settled position and a 3px accent underline.
Focus:focus-visibleFoundation two-tone focus ring on the tab.
Panel shownhidden removed, optional data-forma-motion-entryPanel visible; with the entry hook it fades and rises into place.
Overflowingtabs wider than the listThe list scrolls horizontally inside itself.

Accessibility

Forma provides

  • Keeps tabs as native buttons so they are focusable and activate with Enter or Space.
  • Shows selection with a positional underline plus a surface change, not color alone.
  • Keeps 44px tab height and contains overflow in the list.

Your application supplies

  • Keep aria-selected, tabindex and panel hidden state in sync on every change.
  • Implement arrow, Home and End navigation and choose manual or automatic activation.
  • Make every aria-controls target exist, even for inactive panels.
  • Sync the selected tab with the URL for deep links and restore it on load.

Responsive behavior

  • The tab list scrolls inline (overflow-x: auto, thin scrollbar) instead of wrapping.
  • Tabs keep their intrinsic width; long labels widen the tab rather than truncating.
  • No breakpoints; the same structure is used at every width.

Motion

  • The underline grows from zero width and the selected tab rises 0.08rem into place using the inertial spring timing of the light preset, so the change reads as a quick, light cue.
  • Tab surface color uses the shared perceptual interpolation.
  • A panel with data-forma-motion-entry fades in and rises 0.25rem when it appears.
  • Selection state is set immediately by the application; motion only follows it.
  • Under prefers-reduced-motion: reduce these transitions are effectively instant.

Motion weights

Forma motion is physics-derived: perceived mass changes how a surface accelerates and settles, never what state it is in. Compare the three presentation weights of the same markup:

lightpresentation only

Overview

Current record summary and legal actions supplied by the application.

standardpresentation only

Overview

Current record summary and legal actions supplied by the application.

heavypresentation only

Overview

Current record summary and legal actions supplied by the application.

Usage guidance

Do

  • Use short, noun labels and keep the tab order stable.
  • Put the most used view first.

Avoid

  • Using tabs as page navigation between unrelated destinations.
  • Hiding critical warnings in a non-selected tab.

Verification specimens

Generated fault-injection specimens expose content, spacing, color-cue, and reduced-effective-contrast risks. They screen presentation robustness as engineering screens without claiming human-subject validation.