Record Grid

Free

The data table's `responsive="records"`: a table that becomes a list of records when there is no room to be a table. Below the breakpoint the markup stops claiming to be a table and becomes a list of real <dl> label/value pairs — the structure HTML already has for this — with sorting, selection and row actions rebuilt rather than lost, and nothing dropped.

</>sv-data-table tableresponsivecardsmobilerecords

Complexity tier: Application The interactive bar, plus a stated data-volume ceiling, a persistence contract, a bundle budget and an accessible parity surface.

import { SvDataTableComponent } from '@styloviz/data-table';

Demo & usage

Basic usage

Usage example — open the gallery for the full interactive demo.

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Why not the CSS trick

The technique everyone reaches for sets display:block on the table elements and pipes the column header into each cell through a data-label and a ::before. Two things go wrong and both are invisible. The moment those elements stop being display:table-* the browser drops their table roles, so a screen reader is handed a pile of anonymous blocks instead of rows and columns. And generated content from ::before is not text a user can select, search for or copy. The result looks like labelled cards and is less accessible than the table it replaced.

example.htmlAngular
<!-- What this renders below the breakpoint: a list of records, each a
     real description list. Not a table pretending to be blocks. -->
<ul role="list">
  <li>
    <article aria-labelledby="...">
      <h3 id="...">Ada Lovelace</h3>
      <dl>
        <div><dt>Status</dt><dd>Shipped</dd></div>
        <div><dt>Total</dt><dd>£42.00</dd></div>
      </dl>
    </article>
  </li>
</ul>

Nothing is dropped

The other common answer to a table that does not fit is to hide the columns that do not. A table that silently drops three of its eight fields on a phone is not a responsive table, it is a different table, and nobody is told which one they are reading. A column marked priority: 'secondary' moves behind a per-card disclosure that says how many are in it.

example.htmlAngular
readonly columns: TableColumn[] = [
  { key: 'customer', label: 'Customer' },
  { key: 'total', label: 'Total', sortable: true },
  { key: 'reference', label: 'Reference', priority: 'secondary' },
  { key: 'channel', label: 'Channel', priority: 'secondary' },
];

Sorting has nowhere to live in a card list

The table's sort affordance is the header cell, and a card list has no headers — so a table that becomes cards loses sorting unless the control is rebuilt somewhere else. The records view rebuilds it as a labelled select and a named direction button, and both drive the table's own sort: client-side it reorders, server-side it emits, and switching views never loses it.

example.htmlAngular
<sv-data-table [columns]="columns" [rows]="rows" responsive="records"
  [selectable]="true" [(selectedIds)]="picked" (sortChange)="onSort($event)" />

A narrow panel on a wide screen

A media query measures the viewport, not the panel the table sits in. Where you know the space is narrow, show the records at any width.

example.htmlAngular
<sv-data-table [columns]="columns" [rows]="rows" responsive="records" recordView="always" />
<!-- or move the switch: [recordBreakpoint]="900" -->

When to use

  • Any data table that has to work on a phone — which is most of them.
  • A table embedded in a narrow panel on a wide screen: set `recordView="always"`, because a media query cannot see the panel.
  • For a compact card per row with every column shown (and windowed under `virtualized` on the Pro table), `responsive="cards"` is the lighter option.
  • For a genuinely small set of fields per record, a Descriptions list on its own may be all you need.

Async states

  • loading
  • empty
  • error
  • retry
  • partial

Item identity & owned state

Item key
rowKey — set this when your rows have no id, so selection survives a reorder.
Restorable state
  • expandedRowIds
  • hiddenColumnKeys
  • recordExpandedIds
  • revealedColumnKeys
  • selectedIds

Bind these to put a saved view back — the open sections, the hidden columns, the selected rows — and read their Change events to store what the user does.

Inputs

NameTypeDefaultDescription
columnsTableColumn<T>[][]Column definitions (key, header, alignment, optional cell template).
rowsreadonly T[][]The rows to render. `readonly` on purpose: the table never mutates this array, and anything that hands it one — a signal, a `computed`, `svDataController.items` — is handing over a value it still owns. A mutable `T[]` here rejected every one of those at the template boundary while promising a write the table does not perform.
rowKeySvItemKey<T>'id'What identifies a row: a property name, or a function for composite keys. Widened from `string` because a row identified by two fields — an order line keyed on `orderId` + `lineNo`, a matrix cell on `row` + `col` — had no way to say so, and the fallback silently keyed it on the whole row's JSON. See the identity contract on `resolveItemKey` in `@styloviz/core`.
selectablebooleanfalseEnable row selection.
selectModeSelectMode'multi''multi' = checkboxes, 'single' = radio buttons.
selectedIdsSet<string | number> (two-way)new Set()Selected row ids (two-way).
expandedRowIdsSet<string | number> (two-way)new Set()Which rows have their detail panel open (two-way). A `model` rather than internal state because it is the same kind of fact as `selectedIds`: a host restoring a table after a route change, or opening the row a deep link names, has to be able to write it — and one that persists layout has to be able to see it change. Held in a plain signal it was neither settable nor observable from outside.
actionsTableRowAction<T>[][]Per-row action buttons.
bulkActionsBulkAction[][]Bulk actions applied to selected rows.
loadingbooleanfalseShow a loading state.
loadingStyleLoadingStyle'skeleton''skeleton' rows or full-table 'overlay' spinner.
skeletonRowsnumber5Number of skeleton rows while loading.
paginatedbooleantrueEnable client-side pagination.
pageSizenumber (two-way)10Rows per page (two-way).
pageSizeOptionsnumber[][10, 25, 50]Page-size options offered in the toolbar.
serverSidebooleanfalseServer-side mode: disables client filtering/sorting/paging.
totalCountnumber | nullnullTotal row count when in server-side mode.
variantTableVariant'default'Table style variant.
densityTableDensity'comfortable'Row density: comfortable, compact, etc.
maxHeightstring | nullnullMax body height (CSS length) before the table scrolls.
showScrollHintbooleantrueShow a hint when the table is horizontally scrollable.
rowClassFn((row: T) => string) | nullnullCallback returning extra Tailwind classes for a given row.
showToolbarboolean | undefinedundefinedShow the toolbar strip. Left unset it is derived from whether the toolbar has anything to put in it: a `tableTitle`, or any control it holds — `searchable`, `showDensityToggle`, `showColumnToggle` or `exportable`. Set it explicitly to force the strip on (an empty bar as a spacer) or off (a title used only as the accessible name, or the controls dropped).
tableTitlestring''Title shown in the toolbar.
searchablebooleanfalseShow a search box in the toolbar.
showColumnTogglebooleanfalseShow the column visibility toggle.
exportablebooleanfalseShow an export (CSV) control.
showDensityTogglebooleanfalseShow the density toggle.
columnFiltersbooleanfalseEnable per-column filters.
multiSortbooleanfalseAllow sorting by multiple columns.
expandablebooleanfalseEnable expandable rows.
expandRender((row: T) => string) | nullnullRenderer for the expanded row detail.
showFooterbooleanfalseShow a table footer row.
responsiveDataTableResponsive'none'What the table becomes when there is no room to be a table — see `DataTableResponsive`. `'none'` keeps the table and scrolls it sideways; `'cards'` shows a compact label/value card per row below the `sm` breakpoint; `'records'` shows a list of records below `recordBreakpoint`.
recordTitleKeystring''`responsive="records"`: the column that titles each record. Empty uses the first shown column.
recordBreakpointnumber768`responsive="records"`: width below which the records replace the table, in px.
recordViewDataTableRecordView'auto'`responsive="records"`: `'always'` shows the records at any width — a narrow panel on a wide screen.
recordExpandedIdsReadonlySet<string | number> (two-way)new Set()`responsive="records"`: row keys whose secondary fields are open (two-way), keyed by `rowKey`, never by position, so a host can restore them.
emptyMessagestring'No data to display.'Message shown when there are no rows.
customClassstring''Extra CSS classes for the root element.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`. Rendered in place of the rows, above the toolbar so the user can still change the filter that caused it.
debounceMsnumber300Milliseconds typing in the search box or a text column filter waits before `queryChange` asks the server again (`serverSide` only). The rows on screen still filter on every keystroke; sorting, paging and clearing ask at once. `0` asks on every keystroke.
hiddenColumnKeysSet<string> (two-way)new Set()Which columns the user has hidden (two-way). Bind it to restore a saved set of hidden columns, and read `(hiddenColumnKeysChange)` to store what the user changes.
revealedColumnKeysReadonlySet<string> (two-way)new Set()Columns declared `hidden: true` that the user has since shown from the Columns menu. A `hidden` column starts hidden and stays in the Columns menu, so the user can show it. Two-way, like `hiddenColumnKeys`: together the two ARE the column-visibility view, and a host that persists one without the other restores a table whose revealed columns have vanished again.

Outputs

EventPayload typeDescription
sortChangeSortState[]Emitted with the new sort state when sorting changes.
selectionChangeSet<string | number>Emitted with the set of selected row ids.
rowClickTEmitted with the clicked row.
cellClickCellClickEvent<T>Emitted with the clicked cell context.
editCompleteEditCompleteEvent<T>Emitted when an inline cell edit completes.
retryvoidThe host should re-run the failed load.
queryChangeSvDataQueryEverything the user is asking to see, in the kit's shared shape. This is the output to wire in `serverSide` mode: one handler regardless of whether they paged, sorted, filtered or searched, and the same `SvDataQuery` every other component in the kit emits — so `@styloviz/data` and a hand-rolled fetch both take it without a translation layer.
rowExpandTEmitted with the row when the user expands or collapses its detail panel.
bulkActionClick{ action: BulkAction; selectedIds: Set<string | number> }Emitted with the bulk action and the selected row ids.
selectedIdsChangeSet<string | number>Emits the new `selectedIds` whenever it changes — the output half of `[(selectedIds)]`.
expandedRowIdsChangeSet<string | number>Emits the new `expandedRowIds` whenever it changes — the output half of `[(expandedRowIds)]`.
pageSizeChangenumberEmits the new `pageSize` whenever it changes — the output half of `[(pageSize)]`.
recordExpandedIdsChangeReadonlySet<string | number>Emits the new `recordExpandedIds` whenever it changes — the output half of `[(recordExpandedIds)]`.
hiddenColumnKeysChangeSet<string>Emits the new `hiddenColumnKeys` whenever it changes — the output half of `[(hiddenColumnKeys)]`.
revealedColumnKeysChangeReadonlySet<string>Emits the new `revealedColumnKeys` whenever it changes — the output half of `[(revealedColumnKeys)]`.

<sv-data-table-pro>

Also in this family — SvDataTableProComponent from @styloviz-pro/data-table.

Async states

  • loading
  • empty
  • error
  • retry
  • partial

Item identity & owned state

Item key
rowKey — set this when your rows have no id, so selection survives a reorder.
Restorable state
  • expandedRowIds
  • hiddenColumnKeys
  • recordExpandedIds
  • revealedColumnKeys
  • selectedIds

Bind these to put a saved view back — the open sections, the hidden columns, the selected rows — and read their Change events to store what the user does.

Server writes

Writes
  • batchSave

Each payload carries a requestKey — send it with the request so a retry cannot apply the same change twice.

Rollback
Call event.rollback() when the save fails — the change is already on screen, and this is what puts it back.
While saving
Bind saving — with two writes outstanding there is no single state to roll back to, so the action stays locked until the first one lands.
On failure
Pass the failure to saveError to show it in place — without taking away what the user was working on.

Saved state

Stored kinds
  • sv-data-table/layout

What you will find under your own storage key. You choose the key; the blob names its own kind and schema version, so a component never reads state another one wrote.

Reading it back
Restore through the component's own restore… helper rather than casting the parsed JSON. A blob from an older release is migrated where it can be and refused with a reason where it cannot — so an upgrade never silently applies last month's shape to this month's fields.

Inputs

NameTypeDefaultDescription
columnsTableColumn<T>[][]Column definitions: key, label, alignment, and each column's sorting, filtering, rendering and editing options.
rowsreadonly T[][]The rows to render. `readonly` on purpose: the table never mutates this array, and anything that hands it one — a signal, a `computed`, `svDataController.items` — is handing over a value it still owns. A mutable `T[]` here rejected every one of those at the template boundary while promising a write the table does not perform.
rowKeySvItemKey<T>'id'What identifies a row: a property name, or a function for composite keys. Widened from `string` because a row identified by two fields — an order line keyed on `orderId` + `lineNo`, a matrix cell on `row` + `col` — had no way to say so, and the fallback silently keyed it on the whole row's JSON. See the identity contract on `resolveItemKey` in `@styloviz/core`.
selectablebooleanfalseAdd a selection column of checkboxes (or radio buttons, per `selectMode`).
selectModeSelectMode'multi''multi' = checkboxes, 'single' = radio buttons.
selectedIdsSet<string | number> (two-way)new Set()Ids of the selected rows, as resolved by `rowKey` (two-way).
expandedRowIdsSet<string | number> (two-way)new Set()Which rows have their detail panel open (two-way). A `model` rather than internal state because it is the same kind of fact as `selectedIds`: a host restoring a table after a route change, or opening the row a deep link names, has to be able to write it — and one that persists layout has to be able to see it change. Held in a plain signal it was neither settable nor observable from outside.
actionsTableRowAction<T>[][]Per-row actions, offered in a menu at the end of each row; an action's `hidden` callback can drop it for a given row.
bulkActionsBulkAction[][]Actions shown in a bar above the table while any row is selected; each receives the selected ids and also emits `bulkActionClick`.
loadingbooleanfalseShow the loading state (skeleton rows or an overlay spinner, per `loadingStyle`) and mark the table `aria-busy`.
loadingStyleLoadingStyle'skeleton''skeleton' rows or full-table 'overlay' spinner.
skeletonRowsnumber5Number of placeholder rows (and mobile cards) rendered while `loading` with the skeleton style.
paginatedbooleantrueSplit rows into pages with a pagination bar. Has no effect when `virtualized` or `groupBy` is set.
pageSizenumber (two-way)10Rows per page (two-way); also updated when the user picks a size in the pagination bar.
pageSizeOptionsnumber[][10, 25, 50]Choices in the pagination bar's rows-per-page select; an empty array hides the select.
serverSidebooleanfalseServer-side mode: disables client filtering/sorting/paging.
totalCountnumber | nullnullTotal row count across all pages in `serverSide` mode, used for the range label and page count; falls back to `rows.length` when null.
virtualizedbooleanfalseWindows row rendering to what's scrolled into view, using the same variable-height primitive (`createVariableVirtualizer`, `@styloviz/core`) `list-view` uses — a group header and a data row are different heights, so this table always needs the variable form, never the fixed one. Ignores `paginated`: virtualization and client pagination solve the same problem (a huge row set costing too much DOM), so turning this on reads as opting OUT of pagination rather than stacking both — the same relation `groupBy` has to pagination, and for the same reason.
virtualRowHeightnumber44Approximate pixel height of one data row; the virtualized window is computed from it. Approximate, like `list-view`'s `itemHeight`: measure your own rendered row height for pixel accuracy. A wrong guess still renders every row correctly, with a slightly-off scrollbar length until the next scroll event corrects it.
virtualGroupRowHeightnumber40Pixel height of a collapsible group header row, when `groupBy` is also set.
cardRowHeightnumber96Pixel height of one `responsive="cards"` card; the card list is windowed from it, on the same `virtualized` switch as the table. A card is taller than a row and its height depends on how many columns are visible — a two-column grid of label/value pairs, so roughly `ceil(columns / 2) * 46 + 32`. Approximate for the same reason `virtualRowHeight` is: a wrong guess costs scrollbar accuracy, never correctness.
viewportHeightnumber400Pixel height of the scrolling viewport when `virtualized` is on. A dedicated numeric input rather than reusing `maxHeight` — `maxHeight` accepts any CSS unit (`'50vh'`, `'none'`) that cannot be safely coerced to a pixel count, and the windowing math needs a real number to divide by.
groupBystring | nullnullColumn key to section rows by, with a collapsible header per distinct value. Single-level only — a deliberate scope line: nested/multi-level grouping (which parent collapses which children, aggregate-of-aggregates) is real complexity no showcase use case has asked for, and this shape is additive if a future version needs it.
defaultGroupsExpandedbooleantrueWhether a group starts expanded or collapsed the first time it's seen.
variantTableVariant'default'Visual style: 'default', 'striped' (tinted alternate rows), 'bordered' (cell borders) or 'borderless' (no outer border or row dividers).
layoutTableLayout'default'Layout mode. 'comparison' transposes rows into columns for a product-comparison grid.
highlightRowIdstring | number | nullnullrowKey value of the product column to highlight as "recommended" in comparison layout.
transparentbooleanfalseRemoves the table's own surface fill (root, toolbar, body and rows) so it inherits the background of its container — e.g. when nested inside a glass card or a coloured panel. Row hover/selection tints and the `striped` variant's odd-row tint are preserved. Also drops the card shadow.
densityTableDensity'comfortable'Row padding and text size: 'compact', 'comfortable' or 'spacious'. A choice made in the density toggle overrides it.
maxHeightstring | nullnullMaximum height (any CSS length) of the table's scroll area before it scrolls vertically; ignored when `virtualized`, which uses `viewportHeight`.
showScrollHintbooleantrueShow a fade gradient along the right edge hinting that the table scrolls horizontally.
rowClassFn((row: T) => string) | nullnullCallback returning extra Tailwind classes for a given row.
showToolbarboolean | undefinedundefinedShow the toolbar strip. Left unset it is derived from whether the toolbar has anything to put in it: a `tableTitle`, or any control it holds — `searchable`, `showDensityToggle`, the Columns panel, `findable`, the filter builder, `printable`, or `exportable` with a format to offer. Set it explicitly to force the strip on (an empty bar as a spacer) or off (a title used only as the accessible name, or the controls dropped). Derived, it is also on for `reorderableColumns` / a resizable column: the Columns panel holds those drags' single-pointer alternatives (WCAG 2.5.7). Forcing it off removes them — keep the toolbar when either drag is on.
tableTitlestring''Heading shown in the toolbar; also the table's accessible name and the title of Excel and PDF exports.
searchablebooleanfalseShow a toolbar search box that filters rows by text in any column (sent as `search` in `serverSide` mode).
showColumnTogglebooleanfalseShow a toolbar menu for hiding and showing columns.
exportablebooleanfalseShow a toolbar export control offering the formats in `exportFormats`.
exportFormatsreadonly TableExportFormat[]['csv']Which formats the export control offers, in menu order. One format renders a plain button; more than one renders a menu. Defaults to CSV alone, so `[exportable]="true"` on its own offers a CSV button. Excel and PDF are opt-in: a table offers them only where the host asks (both load `@styloviz-pro/export` as a lazy chunk on first use, and a PDF with fonts set also loads its text shaper then).
exportFileNamestring''Base filename for exports, without extension.
showDensityTogglebooleanfalseShow a toolbar control that lets the user switch row density.
columnFiltersbooleanfalseAdd a filter row beneath the header with a text or select filter per column (per each column's `filterType`).
multiSortbooleanfalseLet Shift+click on a header add a secondary sort instead of replacing the current one.
resizableColumnsbooleanfalseAllow users to drag column edges to resize; the toolbar's Columns panel also offers Narrow / Widen buttons (WCAG 2.5.7).
reorderableColumnsbooleanfalseAllow users to drag headers (or Ctrl/Cmd+←/→) to reorder columns; the toolbar's Columns panel also offers Move left / Move right buttons (WCAG 2.5.7).
expandablebooleanfalseAdd a toggle to each row that opens a detail panel beneath it.
expandRender((row: T) => string) | nullnullReturns the plain text shown in an expanded row's detail panel; when null, the panel lists every column's label and value.
showFooterbooleanfalseShow the summary footer row built from each column's `footerFn`; nothing renders unless at least one column defines one.
responsiveDataTableResponsive'none'What the table becomes when there is no room to be a table — see `DataTableResponsive`. `'none'` keeps the table and scrolls it sideways; `'cards'` shows a compact label/value card per row below the `sm` breakpoint; `'records'` shows a list of records below `recordBreakpoint`.
recordTitleKeystring''`responsive="records"`: the column that titles each record. Empty uses the first shown column.
recordBreakpointnumber768`responsive="records"`: width below which the records replace the table, in px.
recordViewDataTableRecordView'auto'`responsive="records"`: `'always'` shows the records at any width — a narrow panel on a wide screen.
recordExpandedIdsReadonlySet<string | number> (two-way)new Set()`responsive="records"`: row keys whose secondary fields are open (two-way), keyed by `rowKey`, never by position, so a host can restore them.
cellSelectionbooleanfalseSelect a block of cells: drag, Shift+click or Shift+arrows (Ctrl+A all, Shift+Space a row, Ctrl+Space a column); Ctrl/⌘+C copies it as text a spreadsheet reads, Ctrl/⌘+V pastes into it, the corner handle fills (Ctrl+D / Ctrl+R without the drag). The table becomes a `role="grid"`. Writes arrive as one `rangeEdit`; the table never changes `rows`.
cellRangeSvCellRange | null (two-way)nullThe selected block (two-way), by row key and column key. `null` with nothing selected.
contextMenubooleanfalseRight-click (or Shift+F10 / the menu key) on a cell: copy, fill, export the selection, pin or hide the column.
findablebooleanfalseFind in the table — Ctrl/⌘+F inside it, or the toolbar's Find. Marks every match and walks them; unlike search, it hides nothing.
rowNumbersbooleanfalseA leading column numbering the rows through the whole list (page offsets included).
columnBandsreadonly SvColumnBand[][]Headings over runs of columns — a multi-level header. See `SvColumnBand`.
columnPinsReadonly<Record<string, SvColumnPin>> (two-way){}Columns pinned from the context menu (two-way), over each column's own `pinned`: `'left'` / `'right'` (the inline start / end) or `'none'`. Saved with the layout as `columnPins`.
batchEditbooleanfalseEdits, pastes and fills become an undoable draft (Ctrl/⌘+Z, Ctrl/⌘+Shift+Z) the table shows and marks, saved in one `batchSave` — instead of `editComplete` / `rangeEdit` per change.
savingbooleanfalseA `batchSave` is in flight: Save, Discard, Undo and Redo wait for it.
saveErrorSvDataError | string | nullnullThe last `batchSave` failed — shown on the batch bar. Call that save's `rollback()` too.
setFiltersReadonly<Record<string, readonly string[]>> (two-way){}`filterType: 'set'` filters (two-way): column key → the values let through. Saved with the layout.
filterBuilderbooleanfalseA toolbar Filter builder — `@styloviz-pro/query-builder` over the columns (`queryType` per column).
filterQuerySvQueryExpression | null (two-way)nullThe builder's AND/OR query (two-way) — store it with `svSerializeQuery`. `null` filters nothing.
highlightQuerySvQueryExpression | null (two-way)nullRows to mark without hiding the rest (two-way), in the builder's query shape — `svGridAssist` sets it from "highlight …". `null` marks nothing.
statusBarbooleanfalseA bar under the table: the row count, or count / sum / average / min / max of the selected cells.
printablebooleanfalseA toolbar Print button; printing then shows every filtered row and none of the table's controls.
emptyMessagestring'No data to display.'Text shown when there are no rows to display.
customClassstring''Extra CSS classes appended to the root element.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`. Rendered in place of the rows, above the toolbar so the user can still change the filter that caused it.
debounceMsnumber300Milliseconds typing in the search box or a text column filter waits before `queryChange` asks the server again (`serverSide` only). The rows on screen still filter on every keystroke; sorting, paging and clearing ask at once. `0` asks on every keystroke.
hiddenColumnKeysSet<string> (two-way)new Set()Which columns the user has hidden (two-way). Bind it to restore a saved set of hidden columns, and read `(hiddenColumnKeysChange)` to store what the user changes.
revealedColumnKeysReadonlySet<string> (two-way)new Set()Columns declared `hidden: true` that the user has since shown from the Columns menu. A `hidden` column starts hidden and stays in the Columns menu, so the user can show it. Two-way, like `hiddenColumnKeys`: together the two ARE the column-visibility view, and a host that persists one without the other restores a table whose revealed columns have vanished again.

Outputs

EventPayload typeDescription
sortChangeSortState[]Emitted with the full list of active sorts (empty when cleared) whenever the user changes the sort.
selectionChangeSet<string | number>Emitted with the new set of selected row ids whenever the user changes the selection.
rowClickTEmitted with the row when the user clicks a row or one of its cells, or activates it with Enter.
cellClickCellClickEvent<T>Emitted with the row, column and displayed value when the user clicks a cell; `rowClick` fires as well.
editCompleteEditCompleteEvent<T>Emitted with the row, column, old and new value when an inline cell edit is committed with a valid, changed value, so the host can persist it.
rangeEditSvRangeEdit<T>Many cells at once — a paste or a fill (`cellSelection`): every changed cell, validated, in one event to apply in one go.
batchSaveSvBatchSave<T>`batchEdit`: the draft, saved. Apply `changes`, send `requestKey`, call `rollback()` if it fails.
unsavedChangenumber`batchEdit`: how many cells are unsaved, whenever that changes — for a leave-page guard.
retryvoidThe host should re-run the failed load.
queryChangeSvDataQueryEverything the user is asking to see, in the kit's shared shape. This is the output to wire in `serverSide` mode: one handler regardless of whether they paged, sorted, filtered or searched, and the same `SvDataQuery` every other component in the kit emits — so `@styloviz/data` and a hand-rolled fetch both take it without a translation layer.
rowExpandTEmitted with the row when the user expands or collapses its detail panel.
bulkActionClick{ action: BulkAction; selectedIds: Set<string | number> }Emitted with the bulk action and a snapshot of the selected row ids when the user runs a bulk action.
columnResize{ key: string; width: number }A column finished resizing (pointer drag or ←/→ on a focused handle) — emits the column key and its new pixel width, so a host can persist the layout.
columnOrderChangestring[]Columns were reordered by drag — emits the full column-key order, left to right.
exportFailed{ format: TableExportFormat; error: Error }An export failed: a chunk that could not load at click time (offline), a font that could not be read, or an `SvPdfTextError` for a letter no PDF font has. The host learns about it here rather than through an unhandled rejection and a button that appears to do nothing.
groupToggle{ key: string; collapsed: boolean }A group was expanded or collapsed by the user, with its new state.
layoutStateChangeTableLayoutStateFires whenever anything `TableLayoutState` describes changes — column order/width/visibility, sort, column filters, page size, or which groups are collapsed — so a host knows there is something new to save. Store `serializeLayoutState()` rather than this payload: the payload is the live shape, while the serialized form carries a kind and a schema version, and `restoreLayoutState()` can then say why it ignored a blob instead of applying one whose shape does not fit the current table. Does not fire for the state the table mounted with, only for a real change after that, so a host writing straight through to storage does not immediately re-save what it just loaded via `applyLayoutState`.
selectedIdsChangeSet<string | number>Emits the new `selectedIds` whenever it changes — the output half of `[(selectedIds)]`.
expandedRowIdsChangeSet<string | number>Emits the new `expandedRowIds` whenever it changes — the output half of `[(expandedRowIds)]`.
pageSizeChangenumberEmits the new `pageSize` whenever it changes — the output half of `[(pageSize)]`.
recordExpandedIdsChangeReadonlySet<string | number>Emits the new `recordExpandedIds` whenever it changes — the output half of `[(recordExpandedIds)]`.
cellRangeChangeSvCellRange | nullEmits the new `cellRange` whenever it changes — the output half of `[(cellRange)]`.
columnPinsChangeReadonly<Record<string, SvColumnPin>>Emits the new `columnPins` whenever it changes — the output half of `[(columnPins)]`.
setFiltersChangeReadonly<Record<string, readonly string[]>>Emits the new `setFilters` whenever it changes — the output half of `[(setFilters)]`.
filterQueryChangeSvQueryExpression | nullEmits the new `filterQuery` whenever it changes — the output half of `[(filterQuery)]`.
highlightQueryChangeSvQueryExpression | nullEmits the new `highlightQuery` whenever it changes — the output half of `[(highlightQuery)]`.
hiddenColumnKeysChangeSet<string>Emits the new `hiddenColumnKeys` whenever it changes — the output half of `[(hiddenColumnKeys)]`.
revealedColumnKeysChangeReadonlySet<string>Emits the new `revealedColumnKeys` whenever it changes — the output half of `[(revealedColumnKeys)]`.

Wire it to your API

This component is headless about transport: it renders what you give it and reports what the user asks for. Nothing below requires @styloviz/data — it just saves you writing the debounce, the request guard and the retry policy by hand.

Template

Bound to the names this component actually exposes.

usage.htmlAngular
<sv-data-table
  [serverSide]="true"
  [rows]="data.items()"
  [loading]="data.loading()"
  [error]="data.error()"
  [totalCount]="data.total()"
  (queryChange)="data.setQuery($event)"
  (retry)="data.reload()"
/>

Host class

One controller handles debounce, request-guarding, cancellation and retry.

host.component.tsTypeScript
import { svDataController, createHttpDataSource } from '@styloviz/data';

/** Your record type — whatever the endpoint returns per item. */
type Row = { readonly id: string };

readonly data = svDataController(
  createHttpDataSource<Row>({ url: '/api/rows' }),
);
  • `queryChange` carries an `SvDataQuery` — page, page size, sorts, filters, search and cursor in one object. One handler covers every way the user can change what they are asking for.
  • `serverSide` switches **off** the built-in filtering, sorting and paging. Leave it false and the component works entirely from the array you pass — which is what you want for a few hundred rows.
  • `debounceMs` (default 300) collapses a burst of typing into one request. Set it to 0 only when the query is driven by clicks.
  • Normalize failures with `toSvDataError()` from `@styloviz/core`. It derives `retryable` from the status, so a 404 does not get a "Try again" button that can only fail again.

Full walkthrough: Connecting to a backend.

Customization & theming

  • `responsive="records"` with `recordBreakpoint` (default 768) and `recordView` (`auto` / `always`) decides when the records replace the table; `auto` measures the viewport with `matchMedia`, re-measuring when the breakpoint changes, and only while `responsive` is `records`.
  • `recordTitleKey` promotes one field to the record heading; `priority: 'secondary'` on a column moves it behind the per-record disclosure.
  • Selection, sort, `actions` (each `handler` runs), paging, loading and the empty message are the table's own, shared by both views.
  • Two-way `recordExpandedIds` holds which records have their secondary fields open, keyed by `rowKey`, so a host can restore it.
  • Both tiers: `sv-data-table` (`@styloviz/data-table`) and `sv-data-table-pro` (`@styloviz-pro/data-table`). `responsive="records"` is the record-list layout in both.

Best practices

  • Do: Set `recordTitleKey` to the field a reader would use to identify the record. A `<dl>` cannot supply a heading — every pair in it is equally a term — so one field is promoted out, and the default (the first column) is rarely the best one.
  • Do: Mark the fields that matter least as `priority: 'secondary'` rather than removing them from `columns`. They move behind a disclosure that says how many are in it.
  • Do: Use the table's own sort and selection — `(sortChange)`, `[(selectedIds)]`. The records view drives the same state, so switching views never loses a sort or a ticked row.
  • Do: Set `rowKey`. Tracking by position reuses one record's DOM for another on the next sort or page, so a checkbox stays ticked while the record under it changes.
  • Don't: Don't reach for the `display: block` CSS trick instead. It drops the table roles and replaces selectable text with generated content — it looks like this and is less accessible than the table it replaced.

Accessibility

  • Keyboard at scale: the records view renders the page the table is on, so the table's paging bounds it.
  • Below the breakpoint the markup **stops claiming to be a table**. It is a `<ul role="list">` of `<article>` cards, each labelled by its own heading and holding a real `<dl>` of `<dt>`/`<dd>` pairs — which is what a screen reader announces as "Status, definition, Shipped".
  • The labels are real text, not `::before` generated content, so they can be selected, searched and copied.
  • Every control names the record it acts on — "Select Grace Hopper", "Refund Grace Hopper", "Show 2 more fields for Ada Lovelace" — because a card list has no row context to fall back on.
  • The sort control is a labelled `<select>` with a named direction button rather than an icon, since a list of records has no header cell to carry the affordance.
  • A server render shows the table, because a prerender cannot measure and the table is the view that holds every field and every label.

Feedback on Record Grid

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.