<traceability-matrix>
Auto-discovers a 2D cross-reference grid (RTM) from page elements; composes data-table for sortable + heatmap-able presentation, adds chain highlight.
Overview
The <traceability-matrix> component renders the canonical Requirements Traceability Matrix (RTM) shape — rows × columns at-a-glance — by auto-discovering source elements on the page. Use it to verify coverage between personas and stories, stories and work items, requirements and tests, or any other cross-cutting relationship in a planning artifact graph.
It composes <data-table> so the rendered grid is sortable and styleable, and adds two things data-table can't: auto-discovery (you give it CSS selectors, not hand-built rows) and chain highlight (clicking a cell marks the row and column source elements page-wide so authors can see the connection in surrounding components).
How it works
- Author CSS selectors for the row and column source elements (e.g.
rows='[data-row-kind="story"]',cols='[data-row-kind="persona"]'). - Name the link attribute with
link-attr. The component reads each row element's value(s) and matches against the column elements'id. - Comma-separated values are supported out of the box —
data-persona-id="p-sarah,p-jordan"renders two checkmarks. - Orphan flagging — set
flag-orphansto mark empty rows and columns withdata-orphanso CSS can call them out (the default style adds a ⚠ glyph).
Attributes
| Attribute | Values | Default | Description |
|---|---|---|---|
rows | string | — | CSS selector for row source elements |
cols | string | — | CSS selector for column source elements |
link-attr | string | — | Attribute on the row element whose value(s) reference column ids; comma-separated values supported |
label | string | — | Optional heading shown above the matrix |
row-label | string | — | Header cell text for the row axis |
cell-mark | string | — | Glyph shown in linked cells (default: ✓) |
flag-orphans | boolean | — | Mark empty rows/columns with data-orphan for CSS targeting |
Child attributes
| Attribute | On | Values | Description |
|---|---|---|---|
data-matrix-label | * | string | Override the label rendered for this element in matrices that include it |
Persona × Story example
<traceability-matrix rows='[data-row-kind="story"]' cols='[data-row-kind="persona"]' link-attr="data-persona-id" label="Story coverage" row-label="Story" flag-orphans></traceability-matrix> <!-- elsewhere on the page --><article data-row-kind="persona" id="p-sarah" data-matrix-label="Sarah Chen">…</article><article data-row-kind="persona" id="p-alex" data-matrix-label="Alex Rivera">…</article> <article data-row-kind="story" id="s-1" data-persona-id="p-sarah" data-matrix-label="Weekly digest">…</article><article data-row-kind="story" id="s-2" data-persona-id="p-alex" data-matrix-label="Sprint retro">…</article><article data-row-kind="story" id="s-3" data-persona-id="p-sarah,p-jordan" data-matrix-label="Layout review">…</article>
Story × Work-item example
Native VB elements work too — point at <user-story> / <work-item> directly:
<traceability-matrix rows="work-item" cols="user-story" link-attr="story-ids" label="Work item ↔ story" row-label="Work item"></traceability-matrix>
The matrix uses data-matrix-label on each source if present, else its id, else its trimmed text content.
Chain highlight
Clicking any cell in the matrix toggles data-state-highlighted on:
- the cell itself,
- the matrix row,
- the row source element page-wide,
- the column source element page-wide.
The default stylesheet adds an outline to highlighted source elements so authors can scan the page and see the connection. Listen for traceability-matrix:highlight to wire additional behaviour (auto-scroll, side panel, etc.).
document.querySelector('traceability-matrix') .addEventListener('traceability-matrix:highlight', (e) => { const { rowEl, colEl, on } = e.detail; if (on && rowEl) rowEl.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); });
Progressive Enhancement
- HTML. Without JS, the matrix host is empty — auto-discovery is inherently runtime. For no-JS RTMs, render a
<data-table>directly with hand-built intersection rows. The matrix component is purely additive. - CSS. The :not(:defined) selector keeps the host visible pre-upgrade.
- JS. Auto-discovers rows/cols, builds the table, wires chain-highlight clicks, fires
traceability-matrix:ready.
Related
<data-table>— Provides the rendered table; inherits all of its sortable/heatmap behaviour.<quadrant-grid>— 2D primitive for 2x2 categorical layouts (different shape than RTM's intersection grid).<user-persona>,<user-story>,<work-item>— common source elements for the matrix.