VERIFICATION-0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
Version comparison · Extended localized content for verification and layout resilience
2 fields changed
Before
- Status
- Draft
- Owner
- Operations
After
- Status
- Ready for review
- Owner
- Operations
<forma-diff-viewer>
Before/after structured differences with explicit changed-field cues and stacked mobile comparison.
<forma-diff-viewer>patterns/diff-viewer.htmlA diff viewer shows two versions of a structured record side by side: a header stating what is compared and how many fields changed, then a Before and an After column, each a description list of field rows. Rows the application marks with data-change="changed" get a thick inline-start bar. On narrow screens the two columns stack into explicit Before and After sections. Forma does not compute the difference; the application decides which fields differ, in what order they appear and how added or removed values are worded.
repeat(2, minmax(0, 1fr))) separated by a subtle rule; one column at 40rem and below.minmax(7rem, 0.4fr) minmax(0, 1fr)), stacking label over value at 30rem and below.changed is styled. Added and removed values are expressed in text by the application.The smallest correct markup: the canonical pattern from patterns/diff-viewer.html inside its public tag. Copy this first, then adapt labels, names and state.
Rendered from the canonical pattern file.
2 fields changed
<forma-diff-viewer class="forma-component-tag">
<section class="forma-diff-viewer" aria-labelledby="diff-title">
<header class="forma-diff-viewer__header">
<h3 id="diff-title">Version comparison</h3>
<p>2 fields changed</p>
</header>
<div class="forma-diff-viewer__grid">
<section class="forma-diff-viewer__side" aria-label="Previous version">
<h4>Before</h4>
<dl>
<div class="forma-diff-row" data-change="changed"><dt>Status</dt><dd>Draft</dd></div>
<div class="forma-diff-row"><dt>Owner</dt><dd>Operations</dd></div>
</dl>
</section>
<section class="forma-diff-viewer__side" aria-label="Current version">
<h4>After</h4>
<dl>
<div class="forma-diff-row" data-change="changed"><dt>Status</dt><dd>Ready for review</dd></div>
<div class="forma-diff-row"><dt>Owner</dt><dd>Operations</dd></div>
</dl>
</section>
</div>
</section>
</forma-diff-viewer>
Click or tap the code once to select all of it, then copy.
A vendor record where one field was added, one removed and one changed. The row cue marks each difference, and the values say Not set explicitly, so an added field is not mistaken for a blank one. A visually hidden word states the change for screen-reader users.
3 fields changed
<forma-diff-viewer class="forma-component-tag">
<section class="forma-diff-viewer" aria-labelledby="diff-viewer-added-and-removed-title">
<header class="forma-diff-viewer__header">
<h3 id="diff-viewer-added-and-removed-title">Vendor record: revision 7 compared with revision 8</h3>
<p>3 fields changed</p>
</header>
<div class="forma-diff-viewer__grid">
<section class="forma-diff-viewer__side" aria-labelledby="diff-viewer-added-and-removed-before">
<h4 id="diff-viewer-added-and-removed-before">Before (revision 7)</h4>
<dl>
<div class="forma-diff-row"><dt>Name</dt><dd>Coastal Grain Cooperative</dd></div>
<div class="forma-diff-row" data-change="changed"><dt>Payment terms</dt><dd>Net 30 <span class="forma-visually-hidden">(changed)</span></dd></div>
<div class="forma-diff-row" data-change="changed"><dt>Tax exemption</dt><dd>Not set <span class="forma-visually-hidden">(added in revision 8)</span></dd></div>
<div class="forma-diff-row" data-change="changed"><dt>Fax</dt><dd>+32 3 555 0142 <span class="forma-visually-hidden">(removed in revision 8)</span></dd></div>
</dl>
</section>
<section class="forma-diff-viewer__side" aria-labelledby="diff-viewer-added-and-removed-after">
<h4 id="diff-viewer-added-and-removed-after">After (revision 8)</h4>
<dl>
<div class="forma-diff-row"><dt>Name</dt><dd>Coastal Grain Cooperative</dd></div>
<div class="forma-diff-row" data-change="changed"><dt>Payment terms</dt><dd>Net 45 <span class="forma-visually-hidden">(changed)</span></dd></div>
<div class="forma-diff-row" data-change="changed"><dt>Tax exemption</dt><dd>Certificate EX-2291 <span class="forma-visually-hidden">(added)</span></dd></div>
<div class="forma-diff-row" data-change="changed"><dt>Fax</dt><dd>Not set <span class="forma-visually-hidden">(removed)</span></dd></div>
</dl>
</section>
</div>
</section>
</forma-diff-viewer>
Click or tap the code once to select all of it, then copy.
A policy description rewritten between versions. Long values wrap inside the value column on both sides; rows on the two sides do not share heights, so keep the same field order on each side to aid comparison.
1 field changed
<forma-diff-viewer class="forma-component-tag">
<section class="forma-diff-viewer" aria-labelledby="diff-viewer-long-values-title">
<header class="forma-diff-viewer__header">
<h3 id="diff-viewer-long-values-title">Retention policy</h3>
<p>1 field changed</p>
</header>
<div class="forma-diff-viewer__grid">
<section class="forma-diff-viewer__side" aria-label="Published version">
<h4>Published</h4>
<dl>
<div class="forma-diff-row" data-change="changed"><dt>Description</dt><dd>Evidence is kept for 30 days and then deleted automatically unless an administrator places it on hold. <span class="forma-visually-hidden">(changed)</span></dd></div>
<div class="forma-diff-row"><dt>Applies to</dt><dd>All workspaces</dd></div>
</dl>
</section>
<section class="forma-diff-viewer__side" aria-label="Draft version">
<h4>Draft</h4>
<dl>
<div class="forma-diff-row" data-change="changed"><dt>Description</dt><dd>Evidence is kept indefinitely. Exports run automatically after an approver signs off, and deletions require a second approver. <span class="forma-visually-hidden">(changed)</span></dd></div>
<div class="forma-diff-row"><dt>Applies to</dt><dd>All workspaces</dd></div>
</dl>
</section>
</div>
</section>
</forma-diff-viewer>
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 the Before section is followed by the After section, each with its own heading, and each row stacks its label above its value.
.forma-diff-row stacks its label above its value.<forma-diff-viewer class="forma-component-tag">
<section class="forma-diff-viewer" aria-labelledby="diff-viewer-mobile-stacked-diff-title">
<header class="forma-diff-viewer__header">
<h3 id="diff-viewer-mobile-stacked-diff-title">Shipping address</h3>
<p>1 field changed</p>
</header>
<div class="forma-diff-viewer__grid">
<section class="forma-diff-viewer__side" aria-label="Previous address">
<h4>Before</h4>
<dl>
<div class="forma-diff-row" data-change="changed"><dt>Street</dt><dd>14 Harbour Road <span class="forma-visually-hidden">(changed)</span></dd></div>
<div class="forma-diff-row"><dt>City</dt><dd>Antwerp</dd></div>
</dl>
</section>
<section class="forma-diff-viewer__side" aria-label="Current address">
<h4>After</h4>
<dl>
<div class="forma-diff-row" data-change="changed"><dt>Street</dt><dd>2 Kaaiplein, Unit 5 <span class="forma-visually-hidden">(changed)</span></dd></div>
<div class="forma-diff-row"><dt>City</dt><dd>Antwerp</dd></div>
</dl>
</section>
</div>
</section>
</forma-diff-viewer>
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 |
|---|---|---|---|---|
data-change | .forma-diff-row | changed | absent (unchanged) | Marks a field row as different between versions. Written by the application on the row on both sides. |
aria-labelledby | .forma-diff-viewer | id of the header heading | — | Names the comparison. |
aria-label | .forma-diff-viewer__side | string | — | Names each side (Previous version, Current version) when the visible heading is short. |
| Hook | Kind | Values or default | Description |
|---|---|---|---|
.forma-diff-viewer | Block class | — | Bordered root section containing the header and the two sides. |
.forma-diff-viewer__grid | Element class | — | Two equal columns; one column at 40rem and below. |
.forma-diff-viewer__header | Element class | — | Padded header with the comparison title and a change count; ruled below. |
.forma-diff-viewer__side | Element class | — | One version. Padded; the second side is separated by a rule (inline on wide screens, block on narrow). |
.forma-diff-row | Block class | — | A field row inside a side's dl: label/value grid with a subtle bottom rule; stacks at 30rem and below. |
[data-change] | Attribute hook | "changed" | changed on .forma-diff-row adds a 0.3rem accent bar on the inline start and matching inline padding. |
| Keys | Result |
|---|---|
| Tab | Reaches links or controls inside values. The viewer itself has no keyboard behavior; navigation between changes is application behavior. |
Not a form control.
| State | How it is expressed | Presentation |
|---|---|---|
| Unchanged row | .forma-diff-row without data-change | Label and value with a subtle bottom rule. |
| Changed row | data-change="changed" | Inline-start accent bar; CanvasText bar in forced colors. |
| Added or removed value | application text such as Not set, plus data-change="changed" | No separate styling; the wording states which side lacks the value. |
| Stacked | viewport ≤ 40rem | Before and After sections stack; rows stack label over value at 30rem and below. |
data-change is not announced: add text such as a visually hidden "(changed)" in changed values, or list the changes in the header.minmax(0, 1fr)); rows on opposite sides do not align in height when values differ in length.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.