Each row is an independent single-choice question. On narrow screens rows stack into ordinary controls. · Extended localized content for verification and layout resilience
VERIFICATION-0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
<forma-matrix-single>
Repeated single-choice scales arranged as a matrix while retaining per-row radio semantics.
<forma-matrix-single>patterns/matrix-single.htmlA single-choice matrix asks the same scale question about several items. It looks like a table, but it is built from nested fieldsets: the outer fieldset names the whole set and each row is its own fieldset with its own radio group. Screen readers therefore announce the row prompt and the choice label for every radio, and each row validates independently. On narrow screens the rows decompose into ordinary stacked controls rather than relying on horizontal scrolling.
name per row; rows never share a radio group.The smallest correct markup: the canonical pattern from patterns/matrix-single.html inside its public tag. Copy this first, then adapt labels, names and state.
Rendered from the canonical pattern file.
<forma-matrix-single class="forma-component-tag">
<fieldset class="forma-matrix">
<legend class="forma-matrix__legend">Rate each practice.</legend>
<p class="forma-field__description">Each row is an independent single-choice question. On narrow screens rows stack into ordinary controls.</p>
<div class="forma-matrix__rows">
<fieldset class="forma-matrix__row">
<legend>Automated testing</legend>
<div class="forma-matrix__choices">
<label><input type="radio" name="testing-maturity" value="1" required><span>Initial</span></label>
<label><input type="radio" name="testing-maturity" value="2"><span>Developing</span></label>
<label><input type="radio" name="testing-maturity" value="3"><span>Established</span></label>
<label><input type="radio" name="testing-maturity" value="4"><span>Optimized</span></label>
</div>
</fieldset>
<fieldset class="forma-matrix__row">
<legend>Deployment automation</legend>
<div class="forma-matrix__choices">
<label><input type="radio" name="deployment-maturity" value="1" required><span>Initial</span></label>
<label><input type="radio" name="deployment-maturity" value="2"><span>Developing</span></label>
<label><input type="radio" name="deployment-maturity" value="3"><span>Established</span></label>
<label><input type="radio" name="deployment-maturity" value="4"><span>Optimized</span></label>
</div>
</fieldset>
</div>
</fieldset>
</forma-matrix-single>
Click or tap the code once to select all of it, then copy.
Three satisfaction rows after an attempted submit. Two are answered; the unanswered row has aria-invalid and a validation message referenced from its fieldset.
<forma-matrix-single class="forma-component-tag">
<fieldset class="forma-matrix">
<legend class="forma-matrix__legend">How satisfied are you with each tool?</legend>
<div class="forma-matrix__rows">
<fieldset class="forma-matrix__row">
<legend>Issue tracker</legend>
<div class="forma-matrix__choices">
<label><input type="radio" name="matrix-partial-tracker" value="1" required><span>Unsatisfied</span></label>
<label><input type="radio" name="matrix-partial-tracker" value="2"><span>Neutral</span></label>
<label><input type="radio" name="matrix-partial-tracker" value="3" checked><span>Satisfied</span></label>
</div>
</fieldset>
<fieldset class="forma-matrix__row" aria-describedby="matrix-partial-ci-error">
<legend>Continuous integration</legend>
<div class="forma-matrix__choices">
<label><input type="radio" name="matrix-partial-ci" value="1" required aria-invalid="true"><span>Unsatisfied</span></label>
<label><input type="radio" name="matrix-partial-ci" value="2" aria-invalid="true"><span>Neutral</span></label>
<label><input type="radio" name="matrix-partial-ci" value="3" aria-invalid="true"><span>Satisfied</span></label>
</div>
</fieldset>
<p class="forma-validation-message" id="matrix-partial-ci-error">
<span class="forma-validation-message__mark" aria-hidden="true">!</span>
Rate continuous integration before continuing.
</p>
<fieldset class="forma-matrix__row">
<legend>Chat</legend>
<div class="forma-matrix__choices">
<label><input type="radio" name="matrix-partial-chat" value="1" required checked><span>Unsatisfied</span></label>
<label><input type="radio" name="matrix-partial-chat" value="2"><span>Neutral</span></label>
<label><input type="radio" name="matrix-partial-chat" value="3"><span>Satisfied</span></label>
</div>
</fieldset>
</div>
</fieldset>
</forma-matrix-single>
Click or tap the code once to select all of it, then copy.
Row prompts that wrap over several lines, and a fifth Not applicable column that is a real answer in each row. The prompt column keeps a 10rem minimum and wraps.
Choose Not applicable only when the practice does not apply to your service.
<forma-matrix-single class="forma-component-tag">
<fieldset class="forma-matrix">
<legend class="forma-matrix__legend">How consistently does your team follow these practices?</legend>
<p class="forma-field__description">Choose Not applicable only when the practice does not apply to your service.</p>
<div class="forma-matrix__rows">
<fieldset class="forma-matrix__row">
<legend>Every schema migration is reviewed and has a tested rollback path</legend>
<div class="forma-matrix__choices">
<label><input type="radio" name="matrix-long-migrations" value="never" required><span>Never</span></label>
<label><input type="radio" name="matrix-long-migrations" value="sometimes"><span>Sometimes</span></label>
<label><input type="radio" name="matrix-long-migrations" value="usually"><span>Usually</span></label>
<label><input type="radio" name="matrix-long-migrations" value="always"><span>Always</span></label>
<label><input type="radio" name="matrix-long-migrations" value="na"><span>Not applicable</span></label>
</div>
</fieldset>
<fieldset class="forma-matrix__row">
<legend>Feature flags older than 90 days are removed or made permanent</legend>
<div class="forma-matrix__choices">
<label><input type="radio" name="matrix-long-flags" value="never" required><span>Never</span></label>
<label><input type="radio" name="matrix-long-flags" value="sometimes"><span>Sometimes</span></label>
<label><input type="radio" name="matrix-long-flags" value="usually"><span>Usually</span></label>
<label><input type="radio" name="matrix-long-flags" value="always"><span>Always</span></label>
<label><input type="radio" name="matrix-long-flags" value="na"><span>Not applicable</span></label>
</div>
</fieldset>
</div>
</fieldset>
</forma-matrix-single>
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.
At phone width each row becomes a stacked list of choices under its own prompt; no horizontal scrolling is required.
<forma-matrix-single class="forma-component-tag">
<fieldset class="forma-matrix">
<legend class="forma-matrix__legend">Rate each capability.</legend>
<div class="forma-matrix__rows">
<fieldset class="forma-matrix__row">
<legend>Alerting</legend>
<div class="forma-matrix__choices">
<label><input type="radio" name="matrix-mobile-alerting" value="1" required><span>Initial</span></label>
<label><input type="radio" name="matrix-mobile-alerting" value="2"><span>Developing</span></label>
<label><input type="radio" name="matrix-mobile-alerting" value="3"><span>Established</span></label>
</div>
</fieldset>
<fieldset class="forma-matrix__row">
<legend>Runbooks</legend>
<div class="forma-matrix__choices">
<label><input type="radio" name="matrix-mobile-runbooks" value="1" required><span>Initial</span></label>
<label><input type="radio" name="matrix-mobile-runbooks" value="2" checked><span>Developing</span></label>
<label><input type="radio" name="matrix-mobile-runbooks" value="3"><span>Established</span></label>
</div>
</fieldset>
</div>
</fieldset>
</forma-matrix-single>
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 |
|---|---|---|---|---|
type | input | radio | — | Required. One radio per choice in each row. |
name | input | string unique per row | — | Each row has its own name, so each row is its own exclusive answer. |
value | input | string | — | Submitted value for the row. Meaning and scoring stay in the application. |
required | first input of a row | boolean | absent | Makes that row's answer required; rows validate independently. |
checked | input | boolean | absent | Restores a saved row answer. |
aria-invalid | inputs of a row | true | absent | Set by the application on a row that failed validation. |
aria-describedby | row fieldset | id of an error or help element | — | Associates a row-level error or help text with that row. |
| Hook | Kind | Values or default | Description |
|---|---|---|---|
.forma-matrix | Block class | — | Outer fieldset for the whole set, with browser border and padding removed. |
.forma-matrix__choices | Element class | — | Equal columns of at least 5rem for the row's choices; each label is a bordered 44px-tall cell and the radio is visually hidden. |
.forma-matrix__legend | Element class | — | Question text for the whole matrix. |
.forma-matrix__row | Element class | — | Bordered fieldset for one item: prompt column plus choices column. Its legend is floated into the first column. |
.forma-matrix__rows | Element class | — | Grid stacking the rows with a small gap. |
| Keys | Result |
|---|---|
| Tab / Shift+Tab | Moves from one row's radio group to the next; each row is one tab stop. |
| Arrow keys | Moves and selects within the current row only. |
| Space | Selects the focused choice when the row is unanswered. |
| Event | Description |
|---|---|
input / change | Native events from each row's radio group. |
Every row submits its own name=value. Unanswered rows submit nothing; required rows block submission independently.
| State | How it is expressed | Presentation |
|---|---|---|
| Unanswered row | no checked radio in the row | All cells neutral. |
| Selected | :checked | The chosen cell takes the inverse surface. |
| Focus | :focus-visible on the radio | Two-tone focus ring around the cell. |
| Invalid row | aria-invalid plus an application message | Forma adds no row error styling; render a Validation message and reference it from the row. |
minmax(10rem, 1.1fr) for the prompt and minmax(0, 3fr) for the choices.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.