Tabular data component that composes qds-column-header, qds-checkbox, qds-row-actions, qds-pagination, and qds-empty-state.
Use qds-data-table for rows of records the user reads, sorts, selects, and acts on. Do not use it for layout, for a key/value detail panel (that is a description list), or for a spreadsheet-style editable grid — inline editing is a different component with a different interaction model.
Above roughly 2,000 rows in the DOM, this component will feel slow. See the 2,000-row ceiling below.
The component renders a real <table> with <thead>, <tbody>, <tr>, <th>, and <td> elements — not a grid of divs. Native table layout gives correct column sizing, correct colspan, and correct screen-reader navigation for free.
Each <th> contains one qds-column-header and carries aria-sort itself (not the header component). The <th> owns aria-sort because it has role="columnheader".
sort-mode="client": the table sorts rows itself and re-renders.
sort-mode="server": the table fires qds-sort-change and renders whatever rows it is next given, in the given order.
The same split applies to pagination (pagination-mode).
Never mix modes. A table that sorts the current page client-side while the server holds the rest produces an order that is wrong in a way users cannot see.
Select-all applies to the current page only. A select-all that silently spans 1,284 unloaded rows followed by a delete is a data-loss incident. If a select-everything affordance is needed, it is an explicit second action in a selection toolbar, which is not in this component.
Never innerHTML a cell value. Table data comes from an API; a name field containing markup must render as text. The component uses textContent for all cell values, or appends a Node the consumer built themselves via the column render function.
Sticky columns must declare a width. The table computes logical start/end offsets from preceding sticky columns’ widths; without a width the initial offset cannot be calculated. User resizing updates these offsets, including in right-to-left layouts.
Column resizing is opt-in. Set resizable-columns to enable data columns, or set resizable: true on one column. A column’s explicit resizable value overrides the table setting; resizable: false locks it. Selection and row-action columns remain fixed.
Drag a header’s resize separator, use its keyboard controls, or open Column widths above the table to enter an exact pixel width. Resizing uses expand behavior: neighboring columns keep their rendered widths and the table grows or shrinks. Overflow scrolls horizontally; shrinking can leave unused space. Adjacent-column redistribution and automatic content sizing are not supported.
User preferences are stored by stable column key, so sorting, filtering, paging, replacing rows and reordering columns retain them. Each committed snapshot includes measured neighboring widths, including locked data columns. QDS does not write browser storage. Applications can save the complete columnWidths map and restore it through the property; see the persistence example below.
sticky-header needs a scrolling region to stick inside. Set the height constraint on the qds-data-table element itself — for example <qds-data-table sticky-header style="max-height: 400px"> — not on an outer wrapper <div>. The table’s internal [part="scroll"] region is a flex child of the host; a height set on a wrapper around the table doesn’t reach it, so the table just renders at full content height and nothing actually scrolls.
Do not set display on qds-data-table from page-level CSS (e.g. a rule like qds-data-table { display: block } for spacing purposes). The host’s own display: flex is load-bearing for this same reason — a page-level rule with higher specificity than the component’s internal :host rule will win the cascade and silently break the scroll region’s sizing. Use margin for spacing instead.
v1 renders every row. At 40px rows, 2,000 rows is roughly 12,000 cells, which is where scrolling starts to stutter on a mid-range laptop. Mitigations in scope: textContent not innerHTML, DocumentFragment for row building, reused Intl formatter instances per column. Windowing is out of scope. If a consumer needs 10k rows before windowing exists, they paginate at 100.
<qds-data-table id="positions" density="md" selectable sticky-header></qds-data-table>
<script type="module">
const t = document.getElementById('positions');
t.columns = [
{ key: 'symbol', label: 'Symbol', sortable: true, sticky: 'start', width: '120px' },
{ key: 'name', label: 'Name', sortable: true, minWidth: '200px' },
{ key: 'website', label: 'Website', type: 'link', textKey: 'name', target: '_blank' },
{ key: 'quantity', label: 'Quantity', type: 'number', sortable: true },
{ key: 'marketValue', label: 'Market value', type: 'currency', sortable: true },
{ key: 'weight', label: 'Weight', type: 'percent', sortable: true }
];
t.rows = await loadPositions();
t.actions = [
{ id: 'view', label: 'View detail', icon: 'lucide:external-link' },
{ id: 'delete', label: 'Remove position', destructive: true }
];
</script>
| Attribute | Type | Default | Notes |
|---|---|---|---|
density |
sm | md | lg |
md |
Row density: 32/40/48px row height |
striped |
boolean | false |
Zebra striping |
sticky-header |
boolean | false |
Sticky table header |
selectable |
boolean | false |
Leading checkbox column |
resizable-columns |
boolean | false |
Enables data-column resize separators and the Column widths editor; individual columns can override this setting |
selection-mode |
multiple | single |
multiple |
single renders radio-style behaviour with checkboxes |
selected-ids |
string | — | Comma-separated selected row ids |
sort-mode |
client | server |
client |
See client vs server mode |
paginate |
boolean | false |
Renders qds-pagination in the footer |
page |
number | 1 |
Current page, 1-based |
page-size |
number | 25 |
Rows per page |
total |
number | rows.length |
Total row count for pagination |
pagination-mode |
client | server |
client |
See client vs server mode |
row-id-key |
string | id |
Which field identifies a row |
row-label-key |
string | first text column | Used for accessible names in row actions and checkboxes |
empty-title |
string | — | Title for the default empty state |
empty-description |
string | — | Description for the default empty state |
loading |
boolean | false |
Renders skeleton rows, not empty state |
caption |
string | — | Visually hidden <caption> |
| Property | Type | Default | Notes |
|---|---|---|---|
columns |
QdsColumnDef[] |
[] |
Column definitions. Property only — carries functions |
rows |
QdsTableRow[] |
[] |
Row data. Property only |
actions |
QdsRowAction[] |
[] |
Row action definitions. Property only |
sort |
QdsSortState[] |
[] |
Sort state, multi-column in priority order |
selectedIds |
string[] |
[] |
Selected row ids |
resizableColumns |
boolean | false |
Property equivalent of resizable-columns |
columnWidths |
Record<string, number> |
{} |
Committed pixel preferences by column key. Getter returns a copy; setter replaces preferences silently and rejects non-finite/non-positive entries. Positive widths restore verbatim, including neighboring/locked columns; user-edit bounds are not applied to snapshots. Absent and hidden keys are retained for later restoration. |
| Method | Notes |
|---|---|
resetColumnWidths() |
Clears user preferences and restores authored sizing. Does not emit a resize or reset event; applications should also clear their saved preference state. |
columns is an array of QdsColumnDef objects. key identifies the row-data
field; label supplies the column header. Use type for standard formatting,
or render() only when the cell needs custom DOM.
| Field | Type | Notes |
|---|---|---|
key |
string | Required row-data field. For type: 'link', its value is the link URL. |
label |
string | Required header text. |
width |
string | Authored CSS width, such as 200px or 12rem. Required for sticky columns. Restored when user preferences are reset. |
minWidth |
string | Minimum user-resize width, resolved as a CSS length in the current browser context. Missing/invalid minima use 96px. |
maxWidth |
string | Maximum user-resize width, resolved as a CSS length. Missing/invalid maxima are unbounded. A maximum below the minimum resolves to the minimum. |
resizable |
boolean | Overrides resizableColumns for this column. Explicit true enables a column even when the table flag is false; false locks it. |
sortable |
boolean | Enables header sorting; resizing does not activate sorting. |
sticky |
start | end |
Pins a column at the logical edge, including RTL. |
hidden |
boolean | Hides the column without discarding its saved width preference. |
type |
text | number | currency | percent | date | link | custom |
Defaults to text. |
textKey |
string | Link-only. Row field used for link text; defaults to key. |
target |
_self | _blank | _parent | _top |
Link-only. Defaults to _self; _blank automatically adds rel="noopener noreferrer". |
format |
function | Returns plain text. |
render |
function | Returns a DOM Node or plain text for custom cells. |
Use type: 'link' for ordinary row links. The URL comes from key, and the
optional textKey supplies the visible label. The table creates the anchor,
applies QDS link and focus styling, and rejects unsafe URL schemes. Do not put
HTML in row data: it is rendered as text.
{ key: 'website', label: 'Website', type: 'link', textKey: 'name', target: '_blank' }
| Part | Element |
|---|---|
container |
Outer wrapper |
toolbar |
Toolbar slot wrapper |
scroll |
Scroll container |
table |
The table element |
thead |
Table header |
header-row |
Header row |
header-cell |
Header cell (th) |
tbody |
Table body |
row |
Body row |
row-selected |
Added to selected rows |
row-focused |
Added to focused row |
cell |
Body cell |
cell-numeric |
Added to numeric cells |
select-cell |
Selection checkbox cell |
actions-cell |
Row actions cell |
footer |
Footer wrapper |
pagination |
Pagination component |
empty |
Empty state row |
skeleton-row |
Skeleton loading row |
| Property | Default |
|---|---|
--qds-row-height |
var(--qds-control-height-md, 40px) |
--qds-row-font-size |
14px |
--qds-row-padding |
var(--theme-space-3, 12px) |
| Event | When | Detail |
|---|---|---|
qds-sort-change |
Sort changed | { component, sort: QdsSortState[] } |
qds-selection-change |
Selection changed | { component, selectedIds, row? } |
qds-row-click |
Row body clicked or Enter on focused row | { component, rowId, row } |
qds-row-action |
Relayed from qds-row-actions with row populated |
{ component, action, rowId, row } |
qds-page-change |
Relayed from qds-pagination |
{ component, page, pageSize, total } |
qds-column-resize |
A changed user width commits through dragging, keyboard or the numeric editor | { component, key, width, columnWidths: Record<string, number> } |
qds-column-widths-reset |
User chooses Reset all widths in the editor | { component, columnWidths: {} } |
width is in pixels and columnWidths is a defensive snapshot of the committed layout. A resize event is emitted once per changed user commit, not for preview movement. Cancellation, property assignments and resetColumnWidths() do not emit it. The reset event is reserved for the editor’s user action so applications can clear persisted preferences.
| Slot | Purpose |
|---|---|
empty |
Replaces the default empty state |
toolbar |
Above the header — filters, search, bulk actions |
footer |
Below pagination |
Relative bounds such as rem and % are resolved at the start of each gesture or numeric edit. These bounds constrain the column the user edits. The initial responsive table can render other columns below their user-resize minima; their measured widths must remain unchanged when another column is resized. Restoring positive pixel snapshots applies those widths verbatim, without clamping neighboring or locked columns. Keep column keys stable and save the complete map so rerendering and reload reproduce the same layout. Resizing does not mutate the authored column definitions.
This example lets a portfolio reviewer widen company names while keeping symbols fixed. Save only display preferences; no business record changes. The interactive demo includes restore/reset controls, row refresh, a single-column override and a sticky RTL table.
<qds-data-table id="review" resizable-columns caption="Portfolio review"></qds-data-table>
<script type="module">
const table = document.getElementById('review');
const storageKey = 'portfolio-review-column-widths';
table.columns = [
{ key: 'name', label: 'Company', width: '240px', minWidth: '120px', maxWidth: '400px', sortable: true },
{ key: 'symbol', label: 'Symbol', width: '100px', resizable: false },
{ key: 'value', label: 'Market value', type: 'currency', width: '140px', sortable: true }
];
table.rows = [
{ id: '1', name: 'Redwood Energy Partners', symbol: 'RWD', value: 18500000 },
{ id: '2', name: 'Mesa Midstream Holdings', symbol: 'MSA', value: 21250000 }
];
// Storage is optional: malformed or unavailable storage must not block the table.
try {
const saved = JSON.parse(localStorage.getItem(storageKey) || '{}');
if (saved && typeof saved === 'object' && !Array.isArray(saved)) {
table.columnWidths = Object.fromEntries(Object.entries(saved).filter(
([, value]) => typeof value === 'number' && Number.isFinite(value) && value > 0
));
}
} catch { /* Keep the authored layout. */ }
function saveWidths(widths) {
try { localStorage.setItem(storageKey, JSON.stringify(widths)); }
catch { /* Resizing still works when storage is unavailable. */ }
}
table.addEventListener('qds-column-resize', event => saveWidths(event.detail.columnWidths));
table.addEventListener('qds-column-widths-reset', event => saveWidths(event.detail.columnWidths));
// For an application-owned reset button:
// table.resetColumnWidths();
// saveWidths(table.columnWidths);
</script>
<qds-data-table
id="positions"
density="md"
selectable
striped
paginate
page-size="10"
caption="Portfolio positions"
empty-title="No positions yet"
empty-description="Positions appear here once your portfolio is loaded."
>
<div slot="toolbar">
<input type="search" placeholder="Filter positions..." />
</div>
</qds-data-table>
<script type="module">
const table = document.getElementById('positions');
table.columns = [
{ key: 'symbol', label: 'Symbol', sortable: true, sticky: 'start', width: '120px' },
{ key: 'name', label: 'Name', sortable: true, minWidth: '200px' },
{ key: 'website', label: 'Website', type: 'link', textKey: 'name', target: '_blank' },
{ key: 'quantity', label: 'Quantity', type: 'number', sortable: true },
{ key: 'marketValue', label: 'Market value', type: 'currency', sortable: true },
{ key: 'weight', label: 'Weight', type: 'percent', sortable: true }
];
table.rows = [
{ id: '1', symbol: 'AAPL', name: 'Apple Inc.', website: 'https://www.apple.com/', quantity: 100, marketValue: 18500, weight: 0.185 },
{ id: '2', symbol: 'MSFT', name: 'Microsoft Corp.', website: 'https://www.microsoft.com/', quantity: 50, marketValue: 21250, weight: 0.213 },
{ id: '3', symbol: 'GOOGL', name: 'Alphabet Inc.', website: 'https://abc.xyz/', quantity: 30, marketValue: 4200, weight: 0.042 }
];
table.actions = [
{ id: 'view', label: 'View detail', icon: 'pi-external-link' },
{ id: 'delete', label: 'Remove position', destructive: true }
];
table.addEventListener('qds-selection-change', (e) => {
console.log('Selected:', e.detail.selectedIds);
});
table.addEventListener('qds-row-click', (e) => {
console.log('Row clicked:', e.detail.rowId, e.detail.row);
});
</script>