Pairwise choice
<forma-pairwise-choice>
A focused two-alternative comparison using ordinary choice semantics.
- Authoring tag
<forma-pairwise-choice>- Category
- Assessment and survey
- Behavior owner
- Native HTML
- Canonical source
patterns/pairwise-choice.html
Purpose
A pairwise choice asks the user to pick one of two described alternatives, shown side by side as large cards with an "or" between them. It is a native radio group: both cards are labels with visually hidden radios, so the browser owns selection, keyboard movement and required validation. The "Option A / Option B" eyebrow and the "or" separator are presentation; the application decides how many pairs to show, in which order, and what a preference means.
Use when
- A decision or prioritisation exercise compares two alternatives at a time.
- Each alternative needs a title and a short description to be understood.
- A series of pairwise comparisons is used to derive an overall preference.
Avoid when
- The question is yes/no or true/false: use Binary choice.
- There are three or more alternatives: use Choice group or Best–Worst.
- The user must order all alternatives: use Ranking.
- The strength of preference matters: use an Ordinal scale or Semantic differential between the two.
Behavior to know
- Two equal-width cards with an auto-width separator column.
- The whole card is the click and touch target (minimum 5rem tall).
- The separator is
aria-hidden; the radio group semantics communicate that only one can be chosen. - Cards stack vertically below 44rem with the separator centred between them.
Basic example
The smallest correct markup: the canonical pattern from patterns/pairwise-choice.html inside its public tag. Copy this first, then adapt labels, names and state.
Minimal pairwise choice
Rendered from the canonical pattern file.
<forma-pairwise-choice class="forma-component-tag">
<fieldset class="forma-pairwise">
<legend class="forma-pairwise__legend">Which is more important for this decision?</legend>
<div class="forma-pairwise__options">
<label class="forma-pairwise__option">
<input type="radio" name="priority-comparison" value="reliability" required>
<span class="forma-pairwise__eyebrow">Option A</span>
<strong>Reliability</strong>
<span>Prefer predictable operation and recovery.</span>
</label>
<span class="forma-pairwise__versus" aria-hidden="true">or</span>
<label class="forma-pairwise__option">
<input type="radio" name="priority-comparison" value="speed">
<span class="forma-pairwise__eyebrow">Option B</span>
<strong>Delivery speed</strong>
<span>Prefer faster change and deployment.</span>
</label>
</div>
</fieldset>
</forma-pairwise-choice>
Click or tap the code once to select all of it, then copy.
Examples
Second option chosen
Comparison 4 of 10 in a prioritisation exercise with Option B selected. The selected card takes the inverse surface.
<forma-pairwise-choice class="forma-component-tag">
<fieldset class="forma-pairwise" aria-describedby="pairwise-selected-position">
<legend class="forma-pairwise__legend">Which should the platform team invest in next quarter?</legend>
<p class="forma-field__description" id="pairwise-selected-position">Comparison 4 of 10</p>
<div class="forma-pairwise__options">
<label class="forma-pairwise__option">
<input type="radio" name="pairwise-selected-investment" value="observability" required>
<span class="forma-pairwise__eyebrow">Option A</span>
<strong>Observability</strong>
<span>Unified tracing and log search across all services.</span>
</label>
<span class="forma-pairwise__versus" aria-hidden="true">or</span>
<label class="forma-pairwise__option">
<input type="radio" name="pairwise-selected-investment" value="self-service" checked>
<span class="forma-pairwise__eyebrow">Option B</span>
<strong>Self-service environments</strong>
<span>Teams create preview environments without a ticket.</span>
</label>
</div>
</fieldset>
</forma-pairwise-choice>
Click or tap the code once to select all of it, then copy.
Comparison with a No preference answer
When a tie is a legitimate answer, it is offered as a special choice sharing the radio name, below the two cards rather than as a third card between them.
<forma-pairwise-choice class="forma-component-tag">
<fieldset class="forma-pairwise">
<legend class="forma-pairwise__legend">Which matters more for this service?</legend>
<div class="forma-pairwise__options">
<label class="forma-pairwise__option">
<input type="radio" name="pairwise-tie-priority" value="latency" required>
<span class="forma-pairwise__eyebrow">Option A</span>
<strong>Low latency</strong>
<span>Responses under 100ms at the 99th percentile.</span>
</label>
<span class="forma-pairwise__versus" aria-hidden="true">or</span>
<label class="forma-pairwise__option">
<input type="radio" name="pairwise-tie-priority" value="cost">
<span class="forma-pairwise__eyebrow">Option B</span>
<strong>Low running cost</strong>
<span>Stay within the current infrastructure budget.</span>
</label>
</div>
<div class="forma-special-choices" aria-label="Other responses">
<label class="forma-special-choice"><input type="radio" name="pairwise-tie-priority" value="no-preference"><span>No preference</span></label>
</div>
</fieldset>
</forma-pairwise-choice>
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.
Stacked comparison on a phone
Below 44rem the cards stack full width with the separator centred between them.
What changes at narrow widths
- The three-column grid becomes one column: Option A, the "or" separator, then Option B, preserving source order.
- Both cards take the full width, so long titles and descriptions wrap rather than truncate.
- Each card keeps its 5rem minimum height; the entire card is the tap target.
- Nothing scrolls horizontally at 320px, in portrait or landscape.
<forma-pairwise-choice class="forma-component-tag">
<fieldset class="forma-pairwise">
<legend class="forma-pairwise__legend">Which would you rather have?</legend>
<div class="forma-pairwise__options">
<label class="forma-pairwise__option">
<input type="radio" name="pairwise-mobile-tradeoff" value="fewer-meetings" required>
<span class="forma-pairwise__eyebrow">Option A</span>
<strong>Fewer meetings</strong>
<span>Two meeting-free days each week.</span>
</label>
<span class="forma-pairwise__versus" aria-hidden="true">or</span>
<label class="forma-pairwise__option">
<input type="radio" name="pairwise-mobile-tradeoff" value="faster-reviews">
<span class="forma-pairwise__eyebrow">Option B</span>
<strong>Faster reviews</strong>
<span>Code reviews answered within four working hours.</span>
</label>
</div>
</fieldset>
</forma-pairwise-choice>
Click or tap the code once to select all of it, then copy.
Mobile · 320px
The canonical pattern in a true 320px viewport, the minimum width every Forma component must support without page-level horizontal scrolling.
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.
| Attribute | On | Values | Default | Description |
|---|---|---|---|---|
type | input | radio | — | Required. Two radios sharing one name. |
name | input | string | — | Groups the two alternatives. Unique per comparison. |
value | input | string | — | Submitted choice. The application derives preferences; Forma attaches no meaning to A or B. |
required | first input | boolean | absent | Native required-group validation. |
checked | input | boolean | absent | Restores a saved choice. |
aria-hidden | .forma-pairwise__versus | true | — | Keeps the decorative "or" out of the accessibility tree. |
aria-describedby | fieldset | id list | — | Associates help text such as the comparison position. |
| Hook | Kind | Values or default | Description |
|---|---|---|---|
.forma-pairwise | Block class | — | Root fieldset with browser border and padding removed. |
.forma-pairwise__eyebrow | Element class | — | Small uppercase monospace label such as Option A. |
.forma-pairwise__legend | Element class | — | Comparison question. |
.forma-pairwise__option | Element class | — | Bordered card label with a visually hidden radio; at least 5rem tall. |
.forma-pairwise__options | Element class | — | Three-column grid: option, separator, option. One column below 44rem. |
.forma-pairwise__versus | Element class | — | The decorative "or" separator. |
| Keys | Result |
|---|---|
| Tab / Shift+Tab | Moves focus into and out of the comparison. |
| Arrow keys | Native radio behavior: switches and selects between the two alternatives (and any shared special answer). |
| Space | Selects the focused alternative when none is checked. |
| Event | Description |
|---|---|
input / change | Native events from the checked radio. |
Form behavior
Submits name=value for the chosen alternative; unanswered submits nothing and fails required validation.
States
| State | How it is expressed | Presentation |
|---|---|---|
| Unanswered | no checked radio | Both cards neutral. |
| Selected | :checked | The chosen card takes the inverse surface. |
| Focus | :focus-visible on the radio | Two-tone focus ring around the card. |
Accessibility
Forma provides
- Uses a native radio group in a fieldset, so the question and the exclusive choice are announced by the platform.
- Makes each card's full area the target and keeps the title and description inside the label.
- Uses Highlight/HighlightText for the selected card in forced-colors mode.
Your application supplies
- Keep the accessible name meaningful: the card's strong title is read as part of the label, so do not rely on the eyebrow alone.
- Randomise or balance A/B order in application logic if position bias matters.
- Announce progress through a series of comparisons with visible text or Survey progress.
Responsive behavior
- Wide:
minmax(0, 1fr) auto minmax(0, 1fr)keeps the two cards equal regardless of text length. - Below 44rem: one column with the separator centred.
- Card text wraps; there is no horizontal overflow.
Motion
- No animation: the selected card switches surface immediately. The pairwise card is not in the shared transitioned option list.
Usage guidance
Do
- Give both alternatives parallel titles and descriptions of similar length.
- Offer No preference as a Special choice when ties are allowed.
Avoid
- Styling one option as the recommended default.
- Using pairwise comparison for yes/no questions.
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.