Skip to content

Table Set

Customers

View
Customers
AdaLondon12
AlanManchester21
EdsgerRotterdam17

The composed table shell around Table: a title, a column-visibility dropdown, a table ↔ cards view switcher, client-side pagination (or infinite scroll), and optional tabs that switch between distinct views (each with its own columns + rows).

<script>
import TableSet from "@invisible-ui/svelte/TableSet.svelte";
</script>

In Elements, assign data through properties and listen for the bubbling events. Each callback becomes an event with the same name in kebab case, and the no-results “Clear filters” action appears with filters-clearable:

<ds-table-set heading="Customers" page-size="10" configurable allow-view-toggle>
<ds-search-field slot="toolbar" label="Filter customers" hide-label></ds-search-field>
</ds-table-set>
<script type="module">
import "@invisible-ui/elements/define";
const set = document.querySelector("ds-table-set");
set.columns = [
{ key: "name", header: "Name", sortable: true, hideable: false },
{ key: "city", header: "City" },
];
set.rows = customers;
set.addEventListener("page-change", ({ detail }) => console.log(detail.page));
</script>

For a single table, give <ds-table-set> one view. The element it renders each view with is internal, as in the other adapters.

PropTypeDefaultDescription
columnsTableColumnDef[][]Single-view columns (used when views is not provided).
rowsTableRow[][]Single-view rows (used when views is not provided).
viewsTableViewDef[] | undefinedundefinedTabs, each { id, label, columns, rows }.
activeViewstring | undefinedundefinedThe active view id (controlled). Defaults to the first view.
viewsLabelstring | undefinedundefinedAccessible name for the views tab list.
onViewChange((id: string) => void) | undefinedundefinedCalled when the active view changes.
titlestring | undefinedundefinedHeader title.
titleLevel2 | 3 | 4 | 5 | 62
captionstring | undefinedundefinedAccessible name for the table/list (a <caption> in table view).
hideCaptionbooleanfalse
pageSizenumber | undefinedundefinedRows per page (client-side pagination).
pagenumber1
paginationLabelstring | undefinedundefinedAccessible name for the pagination nav. Defaults to the i18n catalog's "Table pages".
onPageChange((page: number) => void) | undefinedundefined
infinitebooleanfalseInfinite-scroll mode instead of pagination.
hasMorebooleanfalseInfinite-scroll mode instead of pagination.
loadingbooleanfalse
onLoadMore(() => void) | undefinedundefinedInfinite-scroll mode instead of pagination.
loadMoreLabelstring | undefinedundefinedLoad-more button text. Defaults to the i18n catalog's "Load more".
loadingLabelstring | undefinedundefinedLoading status text. Defaults to the i18n catalog's "Loading…".
sortSortState | nullnull
onSortChange((sort: SortState | null) => void) | undefinedundefined
hiddenColumnsstring[][]
onHiddenColumnsChange((hidden: string[]) => void) | undefinedundefined
view"table" | "card""table"
allowViewTogglebooleanfalseTable ↔ cards segmented control.
configurablebooleanfalseColumn-visibility dropdown (Popover + checkboxes).
configLabelstring | undefinedundefinedColumn-visibility dropdown label. Defaults to the i18n catalog's "Columns".
cardTitleKeystring | undefinedundefinedMap columns to the card title/description.
cardDescriptionKeystring | undefinedundefinedMap columns to the card title/description.
getValue(row: TableRow, key: string) => unknown(row, key) => row[key]
getRowId(row: TableRow, index: number) => string | numberdefaultGetRowId
selectionModeSelectionMode"none"Row selection: off by default. single or multiple adds the column.
selectedRowIdsRowId[][]The selected row ids (controlled). Replace the array; do not mutate it.
onSelectedRowIdsChange((ids: RowId[]) => void) | undefinedundefinedCalled with the next ids after a user selection action.
isRowSelectable(row: TableRow) => boolean() => trueMarks rows the user may select. Others render without a checkbox.
getRowLabel((row: TableRow) => string) | undefinedundefinedNames a row for its selection checkbox ("Select {name}"). Optional in the type, but required at runtime whenever selection is active.
filtersActivebooleanfalseWhether the consumer's filters are active. Filtering itself stays outside.
totalRowCountnumber | undefinedundefinedTotal unfiltered row count when known; 0 means the dataset is empty.
filterRevisionstring | number | undefinedundefinedChanging this (or filtersActive) resets the local page to one.
onClearFilters(() => void) | undefinedundefinedClears the consumer's filters; enables the built-in no-results action.
noResultsLabelstring | undefinedundefinedCopy for the no-results state. Defaults to the i18n catalog's message.
toolbarSnippet | undefinedundefinedHeader content beside the title, e.g. filters or actions.
cellSnippet<[{ row: TableRow; column: TableColumnDef; value: unknown; rowIndex: number }]> | undefinedundefinedCustom cell content, in the table and in the cards. Defaults to the cell value.

A selected subset of props is shown.

Customers with selection

View
Customers with selection
AdaLondon12
AlanManchester21
EdsgerRotterdam17

Selected: 2

Set selectionMode to single or multiple to add a leading checkbox column. The selection is controlled: pass selectedRowIds and update it from onSelectedRowIdsChange. Ids of rows that are on other pages, filtered out, or no longer selectable are kept as they are; the component never prunes the selection, and switching selectionMode never clears it.

  • Every row needs a stable, unique id: row.id or a custom getRowId. The index fallback of the default getRowId is not accepted for selection, and ids must be unique across all rows the component receives (uniqueness across unloaded server pages is the consumer’s responsibility). The controlled selectedRowIds holds each id once; duplicates are a consumer error.
  • getRowLabel is required while selection is active: it names each row’s checkbox (Select {name}). Empty or whitespace-only labels are invalid.
  • Misuse throws in development. In production the component degrades deterministically (the row is not selectable, the first duplicate wins, the checkbox falls back to the id as its name), but those fallbacks are outside the supported contract.
  • The select-all checkbox addresses only the rendered page’s selectable rows and is disabled when there are none; single mode has no select-all, and re-activating the selected row empties the selection.
  • With tabs (views), the forwarded selection is shared across views. For a per-view selection, swap selectedRowIds from onViewChange.

Customers with filters

Customers with filters
AdaLondon12
AlanManchester21
BarbaraBoston9

Selected: none

Filtering itself stays in the application: predicates, schemas, query state and requests never enter the component. Your filter controls live in the toolbar snippet (a slot="toolbar" child in Elements); the set receives the already-filtered rows plus a few coordination inputs.

  • filtersActive says whether any filter is applied. With zero rows it separates two states: totalRowCount of 0 is an empty dataset (the ordinary empty table), anything else is no results (an Empty State with the noResultsLabel copy and, when onClearFilters is given, a “Clear filters” action).
  • Changing filtersActive or the explicit filterRevision resets the local page to one and reports it through onPageChange exactly once; nothing is emitted on mount, on an unchanged revision, or when already on page one. A new rows array by itself never resets the page.
  • The reset never touches the selection: selected ids survive filter changes, disappearing rows and the clear action.
  • After the built-in clear action brings content back, focus moves to the view container (the activated button unmounts with the panel).
  • Card view is a labelled list of Cards; the column dropdown is a Popover of checkboxes; tabs follow the WAI-ARIA tabs pattern.
  • Selection checkboxes are native inputs with screen-reader-only names; the select-all reflects a partial page with the native indeterminate state. Selected rows carry data-selected for styling.
  • The no-results state is a role="status" Empty State. A separate polite live region, outside the table, announces the result count (“3 results”) when filtering changes it. It stays silent on the first render, when the count is unchanged and when rows arrive with no filtering behind them. The no-results state is said once, by its status. No live region wraps the table itself.
  • A table wider than its card scrolls inside the card. The card takes tabindex="0", role="region" and a name (the title, else the caption) only while it overflows, so the keyboard can scroll it and a table that fits adds no tab stop (WCAG 2.2 1.4.10, 2.1.1).
<TableSet title="Customers" {columns} {rows} configurable allowViewToggle pageSize={10} />

In React, toolbar takes markup and renderCell replaces the cell snippet. Every stateful prop is a controllable mirror, so a parent that holds the selection passes it back down:

<TableSet
title="Customers"
columns={columns}
rows={filteredRows}
pageSize={10}
toolbar={<SearchField label="Filter customers" hideLabel onValueChange={setQuery} />}
filtersActive={query !== ""}
totalRowCount={customers.length}
onClearFilters={() => setQuery("")}
selectionMode="multiple"
selectedRowIds={selected}
onSelectedRowIdsChange={setSelected}
getRowLabel={(row) => String(row.name)}
/>

Themeable via --ds-table-*.