VERIFICATION-0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
| Actions | ||||
|---|---|---|---|---|
| INV-1042 | Acme Manufacturing | Oct 4, 2026 | Overdue | |
| INV-1043 | Northstar Labs | Oct 18, 2026 | Current |
<forma-data-grid>
Semantic tabular records with sortable-column affordances, contained horizontal overflow and a labeled record projection on phones.
<forma-data-grid>patterns/data-grid.htmlA data grid presents a set of records as a native table inside a focusable, labelled scroll region. Forma styles the header, cells, sort indicators and the narrow-screen recomposition: at 30rem and below the header row is hidden and every cell prints its own data-label, so each row reads as a labelled record. Forma does not sort, filter, select, paginate or navigate cells. Header buttons are plain native buttons; the application (normally through Limen) decides what activating them does and writes the resulting aria-sort.
role="grid" keyboard model, which Forma does not provide.data-label.aria-sort, so the visual and the accessibility tree share one source.The smallest correct markup: the canonical pattern from patterns/data-grid.html inside its public tag. Copy this first, then adapt labels, names and state.
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.
| Actions | ||||
|---|---|---|---|---|
| INV-1042 | Acme Manufacturing | Oct 4, 2026 | Overdue | |
| INV-1043 | Northstar Labs | Oct 18, 2026 | Current |
<forma-data-grid class="forma-component-tag">
<div class="forma-data-grid" role="region" tabindex="0" aria-label="Invoice records">
<table>
<caption class="forma-visually-hidden">Invoice records</caption>
<thead>
<tr>
<th scope="col" aria-sort="ascending"><button type="button">Invoice</button></th>
<th scope="col"><button type="button">Customer</button></th>
<th scope="col"><button type="button">Due</button></th>
<th scope="col"><button type="button">Status</button></th>
<th scope="col"><span class="forma-visually-hidden">Actions</span></th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Invoice">INV-1042</td>
<td data-label="Customer">Acme Manufacturing</td>
<td data-label="Due">Oct 4, 2026</td>
<td data-label="Status"><span class="forma-status-lozenge" data-state="attention">Overdue</span></td>
<td data-label="Actions"><button type="button">Open</button></td>
</tr>
<tr>
<td data-label="Invoice">INV-1043</td>
<td data-label="Customer">Northstar Labs</td>
<td data-label="Due">Oct 18, 2026</td>
<td data-label="Status"><span class="forma-status-lozenge" data-state="ok">Current</span></td>
<td data-label="Actions"><button type="button">Open</button></td>
</tr>
</tbody>
</table>
</div>
</forma-data-grid>
Click or tap the code once to select all of it, then copy.
The application has sorted by Due in descending order, so only that header carries aria-sort="descending" and shows a down arrow. Row actions name their record so a list of Open buttons is not ambiguous out of context.
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.
| Actions | ||||
|---|---|---|---|---|
| INV-1051 | Harbor Freight Partners | Draft | ||
| INV-1047 | Northstar Labs | Payment unconfirmed | ||
| INV-1042 | Acme Manufacturing | Overdue |
<forma-data-grid class="forma-component-tag">
<div class="forma-data-grid" role="region" tabindex="0" aria-label="Invoices by due date">
<table>
<caption class="forma-visually-hidden">Invoices sorted by due date, newest first</caption>
<thead>
<tr>
<th scope="col"><button type="button">Invoice</button></th>
<th scope="col"><button type="button">Customer</button></th>
<th scope="col" aria-sort="descending"><button type="button">Due</button></th>
<th scope="col"><button type="button">Status</button></th>
<th scope="col"><span class="forma-visually-hidden">Actions</span></th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Invoice">INV-1051</td>
<td data-label="Customer">Harbor Freight Partners</td>
<td data-label="Due"><time datetime="2026-11-02">Nov 2, 2026</time></td>
<td data-label="Status"><span class="forma-status-lozenge">Draft</span></td>
<td data-label="Actions"><button type="button" aria-label="Open INV-1051">Open</button></td>
</tr>
<tr>
<td data-label="Invoice">INV-1047</td>
<td data-label="Customer">Northstar Labs</td>
<td data-label="Due"><time datetime="2026-10-18">Oct 18, 2026</time></td>
<td data-label="Status"><span class="forma-status-lozenge" data-state="unknown">Payment unconfirmed</span></td>
<td data-label="Actions"><button type="button" aria-label="Open INV-1047">Open</button></td>
</tr>
<tr>
<td data-label="Invoice">INV-1042</td>
<td data-label="Customer">Acme Manufacturing</td>
<td data-label="Due"><time datetime="2026-10-04">Oct 4, 2026</time></td>
<td data-label="Status"><span class="forma-status-lozenge" data-state="attention">Overdue</span></td>
<td data-label="Actions"><button type="button" aria-label="Open INV-1042">Open</button></td>
</tr>
</tbody>
</table>
</div>
</forma-data-grid>
Click or tap the code once to select all of it, then copy.
The query returned no records. The header row stays so the columns still explain what would appear, and an Empty state after the region says why the table is empty and how to recover. Forma does not decide between empty, loading and failed; the application renders the right one.
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.
Every invoice due before today has been paid or written off.
<forma-data-grid class="forma-component-tag">
<div class="forma-stack" data-density="compact">
<div class="forma-data-grid" role="region" tabindex="0" aria-label="Overdue invoices">
<table>
<caption class="forma-visually-hidden">Overdue invoices</caption>
<thead>
<tr>
<th scope="col"><button type="button">Invoice</button></th>
<th scope="col"><button type="button">Customer</button></th>
<th scope="col" aria-sort="ascending"><button type="button">Due</button></th>
<th scope="col"><button type="button">Status</button></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<section class="forma-empty-state" aria-labelledby="data-grid-empty-result-title">
<div class="forma-empty-state__symbol" aria-hidden="true">□</div>
<h3 id="data-grid-empty-result-title">No overdue invoices</h3>
<p>Every invoice due before today has been paid or written off.</p>
<button type="button">Show all invoices</button>
</section>
</div>
</forma-data-grid>
Click or tap the code once to select all of it, then copy.
Seven columns exceed a tablet-width container, so the table scrolls inside the labelled region rather than widening the page. The region is focusable, so keyboard users can scroll it with the arrow keys. Long customer names wrap inside their cells.
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.
| Actions | ||||||
|---|---|---|---|---|---|---|
| SHP-2026-000418 | Rheinland Präzisionswerkzeuge und Industriebedarf GmbH | Rotterdam, NL | Duisburg, DE | 12,480 kg | Delivered | |
| SHP-2026-000419 | Coastal Grain Cooperative | Antwerp, BE | Lyon, FR | — | Held at customs |
<forma-data-grid class="forma-component-tag">
<div class="forma-data-grid" role="region" tabindex="0" aria-label="Shipment records">
<table>
<caption class="forma-visually-hidden">Shipment records</caption>
<thead>
<tr>
<th scope="col" aria-sort="ascending"><button type="button">Shipment</button></th>
<th scope="col"><button type="button">Consignee</button></th>
<th scope="col"><button type="button">Origin</button></th>
<th scope="col"><button type="button">Destination</button></th>
<th scope="col"><button type="button">Weight</button></th>
<th scope="col"><button type="button">Status</button></th>
<th scope="col"><span class="forma-visually-hidden">Actions</span></th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Shipment"><span class="forma-identifier">SHP-2026-000418</span></td>
<td data-label="Consignee">Rheinland Präzisionswerkzeuge und Industriebedarf GmbH</td>
<td data-label="Origin">Rotterdam, NL</td>
<td data-label="Destination">Duisburg, DE</td>
<td data-label="Weight">12,480 kg</td>
<td data-label="Status"><span class="forma-status-lozenge" data-state="ok">Delivered</span></td>
<td data-label="Actions"><button type="button" aria-label="Open SHP-2026-000418">Open</button></td>
</tr>
<tr>
<td data-label="Shipment"><span class="forma-identifier">SHP-2026-000419</span></td>
<td data-label="Consignee">Coastal Grain Cooperative</td>
<td data-label="Origin">Antwerp, BE</td>
<td data-label="Destination">Lyon, FR</td>
<td data-label="Weight">—</td>
<td data-label="Status"><span class="forma-status-lozenge" data-state="blocked">Held at customs</span></td>
<td data-label="Actions"><button type="button" aria-label="Open SHP-2026-000419">Open</button></td>
</tr>
</tbody>
</table>
</div>
</forma-data-grid>
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 header row disappears and each row becomes a bordered record whose cells print their data-label. The row action stretches to the full record width.
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.
thead is hidden and every td shows its data-label in a 6.5rem label column beside the value.td[data-label="Actions"] cell stretch to 100% width, giving a full-width touch target per record.thead, so sorting is not reachable on phones from the grid itself. Offer sort in a Collection toolbar or equivalent control.<forma-data-grid class="forma-component-tag">
<div class="forma-data-grid" role="region" tabindex="0" aria-label="Open support tickets">
<table>
<caption class="forma-visually-hidden">Open support tickets</caption>
<thead>
<tr>
<th scope="col" aria-sort="ascending"><button type="button">Ticket</button></th>
<th scope="col"><button type="button">Subject</button></th>
<th scope="col"><button type="button">Status</button></th>
<th scope="col"><span class="forma-visually-hidden">Actions</span></th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Ticket">SUP-3120</td>
<td data-label="Subject">Cannot export the quarterly usage report as CSV</td>
<td data-label="Status"><span class="forma-status-lozenge" data-state="attention">Awaiting reply</span></td>
<td data-label="Actions"><button type="button" aria-label="Open SUP-3120">Open</button></td>
</tr>
<tr>
<td data-label="Ticket">SUP-3124</td>
<td data-label="Subject">Single sign-on loop after password change</td>
<td data-label="Status"><span class="forma-status-lozenge">New</span></td>
<td data-label="Actions"><button type="button" aria-label="Open SUP-3124">Open</button></td>
</tr>
</tbody>
</table>
</div>
</forma-data-grid>
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.
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.
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 |
|---|---|---|---|---|
role | .forma-data-grid | region | — | Makes the scroll container a named landmark so keyboard and screen-reader users can find and scroll it. |
tabindex | .forma-data-grid | 0 | — | Lets keyboard users focus the region and scroll overflowing columns with the arrow keys. |
aria-label | .forma-data-grid | string | — | Names the region. Use a distinct name per grid on the page. |
scope | th | col | — | Associates each header with its column on wide layouts. |
aria-sort | th | ascending | descending | absent (unsorted) | Written by the application on the one sorted column. Forma appends ↑ or ↓ to the header button from this value. |
data-label | td | column name | — | Required on every cell. Printed as the cell's label at 30rem and below, when the header row is hidden. Actions also stretches the cell's children to full width. |
type | button | button | — | Header sort buttons and row actions are native buttons; type="button" prevents accidental form submission. |
aria-label | row action button | string | — | Names the record a repeated action applies to, such as "Open INV-1042". |
datetime | time | ISO date | — | Machine-readable date for date cells; the visible text stays human-formatted. |
| Hook | Kind | Values or default | Description |
|---|---|---|---|
.forma-data-grid | Block class | — | Root scroll region around the native table. Bordered, horizontally scrollable, and recomposed into labelled records at 30rem and below. |
| Keys | Result |
|---|---|
| Tab / Shift+Tab | Moves through the region, the header sort buttons and row actions in document order. |
| Arrow keys | Scroll the focused region horizontally and vertically (native scrolling). There is no cell-by-cell navigation. |
| Enter / Space | Activate a focused sort button or row action. What sorting does is application behavior. |
| Event | Description |
|---|---|
click | Native click on header and row buttons. The application sorts or navigates, then re-renders rows and moves aria-sort. |
Not a form control. Row selection checkboxes or inline inputs, if added, participate in their own form as ordinary native controls.
| State | How it is expressed | Presentation |
|---|---|---|
| Unsorted | no aria-sort on any th | Header buttons show their label only. |
| Sorted ascending | aria-sort="ascending" on th | The header button shows an up arrow after its label; assistive technology announces the sort. |
| Sorted descending | aria-sort="descending" on th | The header button shows a down arrow after its label. |
| Overflowing | table wider than the region | The region scrolls horizontally inside its border because the table keeps a 42rem minimum width. |
| Record projection | viewport ≤ 30rem | Header hidden; rows are bordered records; cells show their data-label. |
| Empty | empty tbody plus an application-rendered Empty state | Forma has no built-in empty row; the application explains the absence of records. |
table with th scope, so row and column relationships come from the platform on wide layouts.aria-sort, so the visible indicator cannot disagree with what assistive technology announces.data-label, replacing the hidden header.caption (it may be visually hidden) and a unique aria-label on the region.data-label on every td, matching the column header text.aria-sort to the sorted column and announce sort or result changes in a live region such as the Collection toolbar count..forma-data-grid region scrolls horizontally, so the page never overflows.thead hidden, every cell a minmax(6.5rem, 0.4fr) minmax(0, 1fr) label/value grid.data-label and any sort control wording identical.aria-sort.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.