Primary narrative
The main content owns most available width.
<forma-switcher>
Keeps related regions side by side when space permits and stacks them without semantic reordering.
<forma-switcher>patterns/switcher.htmlA switcher holds a primary region and a secondary region in one row while both fit at useful widths, and stacks them as whole blocks when they do not. Unlike a cluster, it never leaves a region squeezed at an awkward in-between width: the primary region wants about 28rem and the secondary about 16rem, and as soon as the row cannot hold both, each takes a full line. The decision comes from the switcher's own width, so it behaves the same in a page, a panel or a dialog.
The smallest correct markup: the canonical pattern from patterns/switcher.html inside its public tag. Copy this first, then adapt labels, names and state.
Rendered from the canonical pattern file.
The main content owns most available width.
<forma-switcher class="forma-component-tag">
<section class="forma-switcher" aria-label="Narrative and supporting material">
<article class="forma-switcher__primary"><h2>Primary narrative</h2><p>The main content owns most available width.</p></article>
<aside class="forma-switcher__secondary" aria-label="Supporting material"><h2>Supporting material</h2><p>Secondary content remains adjacent when space permits.</p></aside>
</section>
</forma-switcher>
Click or tap the code once to select all of it, then copy.
A payment details form with a help panel. The form is the primary region; the help panel sits beside it on wide screens and below it when the pane narrows.
Static specimen. Submitting or resetting it needs the consuming application's form handling, which this documentation does not have. Its controls are shown for their markup and appearance and cannot be operated here.
<forma-switcher class="forma-component-tag">
<div class="forma-switcher">
<form class="forma-switcher__primary forma-stack" aria-labelledby="switcher-form-with-help-title">
<h2 id="switcher-form-with-help-title">Bank account</h2>
<div class="forma-field">
<label class="forma-field__label" for="switcher-form-with-help-holder">Account holder</label>
<input id="switcher-form-with-help-holder" name="holder" type="text" autocomplete="name">
</div>
<div class="forma-field">
<label class="forma-field__label" for="switcher-form-with-help-iban">IBAN</label>
<input id="switcher-form-with-help-iban" name="iban" type="text" autocomplete="off" spellcheck="false">
</div>
<div class="forma-cluster"><button type="submit">Save account</button></div>
</form>
<aside class="forma-switcher__secondary forma-surface" aria-labelledby="switcher-form-with-help-help">
<h3 id="switcher-form-with-help-help">Where to find your IBAN</h3>
<p>It is printed on your bank statement and shown in your banking app under account details.</p>
</aside>
</div>
</forma-switcher>
Click or tap the code once to select all of it, then copy.
A change summary with the current configuration as the primary region and the proposed change as the secondary. A narrower gap is set with --forma-switcher-space.
Audit logs are kept for 90 days and then deleted. Exports are available for the full period.
Keep audit logs for 400 days.
<forma-switcher class="forma-component-tag">
<section class="forma-switcher" style="--forma-switcher-space: 1rem" aria-label="Retention policy change">
<article class="forma-switcher__primary forma-surface" aria-labelledby="switcher-comparison-before-after-current">
<h2 id="switcher-comparison-before-after-current">Current policy</h2>
<p>Audit logs are kept for 90 days and then deleted. Exports are available for the full period.</p>
</article>
<article class="forma-switcher__secondary forma-surface" aria-labelledby="switcher-comparison-before-after-proposed">
<h2 id="switcher-comparison-before-after-proposed">Proposed policy</h2>
<p>Keep audit logs for 400 days.</p>
</article>
</section>
</forma-switcher>
Click or tap the code once to select all of it, then copy.
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.
A release note with a supporting download panel at phone width. The row cannot hold both minimums, so the regions stack.
Static specimen. Its links point to placeholder destinations that do not exist on this site. Its controls are shown for their markup and appearance and cannot be operated here.
min(100%, …), so at 320px neither region forces horizontal scrolling.<forma-switcher class="forma-component-tag">
<div class="forma-switcher">
<article class="forma-switcher__primary forma-stack" aria-labelledby="switcher-mobile-stacked-title">
<h2 id="switcher-mobile-stacked-title">Version 5.1</h2>
<p>Offline mode now syncs drafts automatically when the connection returns.</p>
</article>
<aside class="forma-switcher__secondary" aria-labelledby="switcher-mobile-stacked-download">
<h3 id="switcher-mobile-stacked-download">Download</h3>
<p><a href="#release-5-1">Release notes and installers</a></p>
</aside>
</div>
</forma-switcher>
Click or tap the code once to select all of it, then copy.
The canonical pattern in a true 320px viewport, the minimum width every Forma component must support without page-level horizontal scrolling.
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.
| Attribute | On | Values | Default | Description |
|---|---|---|---|---|
aria-labelledby | regions | id of the region heading | — | Names each region by its visible heading. |
aria-label | .forma-switcher | string | — | Names the pair when the switcher element is a section. |
style | .forma-switcher | --forma-switcher-space: <length> | — | Per-instance gap override. |
| Hook | Kind | Values or default | Description |
|---|---|---|---|
.forma-switcher | Block class | — | Wrapping flex container with start-aligned regions. |
.forma-switcher__primary | Element class | — | Primary region: flex basis 28rem, grows strongly, minimum min(100%, 20rem). |
.forma-switcher__secondary | Element class | — | Secondary region: flex basis 16rem, minimum min(100%, 16rem). |
--forma-switcher-space | Custom property | default var(--forma-primitive-spacing-5, 1.5rem) | Gap between the regions in both directions. Default --forma-primitive-spacing-5 (1.5rem). |
--forma-switcher-threshold | Custom property | default 42rem | Declared with a default of 42rem but not read by any rule; setting it currently has no effect. The switch point comes from the region flex bases. |
| Keys | Result |
|---|---|
| Tab / Shift+Tab | Moves through the primary region, then the secondary, in source order. |
Not a form control.
| State | How it is expressed | Presentation |
|---|---|---|
| Side by side | row holds both flex bases | Primary region takes most of the width; secondary keeps about 16rem. |
| Stacked | row too narrow for both | Each region is full width, in source order. |
--forma-switcher-threshold to control the switch point; it is not wired to any rule.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.