Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Data

DataTable <pm-data-table>

Advanced data table for business apps: search, filters, sorting, frozen columns, selection, grouping, editing and export.

Full screen
New invoice

Props

<script type="module"> import '@prismora/css'; import '@prismora/elements/button'; import '@prismora/elements/data-table'; import { registerIcons } from '@prismora/elements/icon'; import { plus } from '@prismora/icons'; registerIcons([plus]); </script> <pm-data-table label="Invoices" page-size="8" page-sizes='[8,25,50]' selectable searchable column-picker exportable max-height="20rem" pinned-rows='["INV-1048"]' columns='[{"key": "id", "label": "Invoice", "sortable": true, "pin": "start", "width": "8rem"}, {"key": "region", "label": "Region", "sortable": true, "filter": "select", "merge": true}, {"key": "customer", "label": "Customer", "sortable": true, "filter": "text", "group": "Account", "editable": true}, {"key": "owner", "label": "Owner", "sortable": true, "group": "Account", "hidden": false}, {"key": "status", "label": "Status", "sortable": true, "filter": "select", "options": ["Paid", "Pending", "Overdue"], "editable": true}, {"key": "issued", "label": "Issued", "sortable": true, "type": "date", "group": "Dates"}, {"key": "due", "label": "Due", "sortable": true, "type": "date", "group": "Dates"}, {"key": "amount", "label": "Amount", "sortable": true, "type": "currency", "currency": "USD", "filter": "number", "aggregate": "sum", "pin": "end", "editable": true}]' rows='[{"id": "INV-1042", "region": "EMEA", "customer": "Acme Corp", "owner": "Ada", "status": "Paid", "issued": "2026-01-01", "due": "2026-02-01", "amount": 1200}, {"id": "INV-1043", "region": "EMEA", "customer": "Globex", "owner": "Grace", "status": "Pending", "issued": "2026-02-04", "due": "2026-03-04", "amount": 860}, {"id": "INV-1044", "region": "EMEA", "customer": "Initech", "owner": "Linus", "status": "Overdue", "issued": "2026-03-07", "due": "2026-04-07", "amount": 2310}, {"id": "INV-1045", "region": "Americas", "customer": "Umbrella", "owner": "Margaret", "status": "Paid", "issued": "2026-04-10", "due": "2026-05-10", "amount": 475}, {"id": "INV-1046", "region": "Americas", "customer": "Hooli", "owner": "Ada", "status": "Pending", "issued": "2026-05-13", "due": "2026-06-13", "amount": 3900}, {"id": "INV-1047", "region": "Americas", "customer": "Stark Ind.", "owner": "Grace", "status": "Overdue", "issued": "2026-06-16", "due": "2026-07-16", "amount": 150}, {"id": "INV-1048", "region": "Americas", "customer": "Wayne Ent.", "owner": "Linus", "status": "Paid", "issued": "2026-07-19", "due": "2026-08-19", "amount": 7420}, {"id": "INV-1049", "region": "APAC", "customer": "Soylent", "owner": "Margaret", "status": "Pending", "issued": "2026-08-22", "due": "2026-09-22", "amount": 980}, {"id": "INV-1050", "region": "APAC", "customer": "Wonka", "owner": "Ada", "status": "Overdue", "issued": "2026-09-25", "due": "2026-10-25", "amount": 640}, {"id": "INV-1051", "region": "APAC", "customer": "Tyrell", "owner": "Grace", "status": "Paid", "issued": "2026-01-01", "due": "2026-02-01", "amount": 5210}, {"id": "INV-1052", "region": "APAC", "customer": "Cyberdyne", "owner": "Linus", "status": "Pending", "issued": "2026-02-04", "due": "2026-03-04", "amount": 1330}, {"id": "INV-1053", "region": "APAC", "customer": "Aperture", "owner": "Margaret", "status": "Overdue", "issued": "2026-03-07", "due": "2026-04-07", "amount": 2775}]'> <pm-button slot="toolbar" size="sm" variant="outline" tone="neutral" icon-start="plus">New invoice</pm-button> </pm-data-table>

Overview

Everything is optional and driven by column definitions:

  • Find: global search box (searchable), per-column filters (text, select, number ranges), multi-column sort (Shift+click adds a sort level).
  • Columns: freeze (pin: 'start' | 'end'), resize (drag or keyboard), reorder (drag headers or the column menu), show/hide (column-picker), header groups (group), and a per-column actions menu.
  • Rows: single or multi selection (Shift+click for ranges, "select all N" across pages), pinned rows that stay on top (pinned-rows), expandable detail rows (expandable + renderDetail), grouping with counts (group-by), merged cells (merge → rowspan, colSpan → colspan), inline editing.
  • Data: client-side paging or manual for server-side (events carry the full query), footer aggregates (sum/avg/min/max/count), Intl formatting by type, CSV export (exportable / toCsv()), infinite loading (pm-end-reached), saved views (state, persist).
  • Use: spreadsheet-style keyboard grid (arrows, Home/End, PageUp/Down, Enter/F2 to edit, Space to select), sticky header and footer, loading bar, labelled cards in narrow containers, every UI string replaceable.
  • Content: per column render(row) (text, DOM node or Lit template), light-DOM <template data-cell="key"> with escaped {{field}} placeholders, format(value, row), or Intl formatting by type (number, currency, percent, bytes, date, datetime, time, boolean) with formatOptions and prefix/suffix. Headers the same way: renderHeader(col) or <template data-header="key">; label stays the accessible and CSV name.

Server-side data: set src to a URL (src="/api/orders"; the query goes in as q, page, pageSize, sort, order, sorts and filter[key] parameters, or as {placeholders} in the URL) and say where the rows and the total are in the JSON (rows-path="data", total-path="meta.total"), or set the loader property to your own async (query, { signal }) => ({ rows, total }). mapRow formats each server row. Searching, sorting, filtering and paging then reload from the server (search debounced by debounce), superseded requests are cancelled, and loading and error (with Retry) states show. reload() fetches the current page again.

Columns and rows can be properties or JSON attributes (columns='[{"key":"name","label":"Name","sortable":true}]'). For a light table without these features use <pm-table>.

Attributes

AttributeTypeDefaultDescription
columnsDataTableColumn<R>[][]Column definitions: key, label, type, sorting, filters, pinning, grouping, merging, editing and rendering.
rowsR[][]Row objects (or a JSON string). In manual mode, the current page from your server.
labelstring—Accessible name (caption).
row-key
prop: rowKey
stringidField that identifies a row (default "id", else its position).
stack'auto' | 'never'—Narrow containers (< 36rem): auto shows rows as labelled cards; never keeps a horizontally scrolling table.
selectablebooleanfalseShow row checkboxes (see selection for single or multiple).
selection'single' | 'multiple'—multiple (default, checkboxes) or single (radio buttons).
filterstring—Global search text (matches any visible column, raw or formatted).
page-size
prop: pageSize
number0Rows per page (0 = no paging).
pagenumber1Current page, starting at 1.
totalnumber—Total rows on the server (with manual).
manualbooleanfalseRows are already sorted, filtered and paged by the server: render them and emit events with the query.
loadingbooleanfalseShow a loading state (and mark the region busy for assistive tech).
stripedbooleanfalseShade alternate rows.
empty-text
prop: emptyText
string—Text shown when there is nothing to list.
row-clickable
prop: rowClickable
booleanfalseEmit pm-row-click and show a pointer on rows.
searchablebooleanfalseShow a search box in the toolbar.
column-picker
prop: columnPicker
booleanfalseShow a Columns menu to show, hide and reset columns.
exportablebooleanfalseShow an Export CSV button.
column-menu
prop: columnMenu
booleantruePer-column actions menu in each header (default on; column-menu="false" to hide).
group-by
prop: groupBy
string—Group rows by this column key (collapsible group headers with counts).
expandablebooleanfalseAdd a toggle that shows renderDetail(row) under the row.
pinned-rows
prop: pinnedRows
string[][]Row keys pinned to the top (always visible, stay under the header while scrolling).
localestring—BCP 47 locale for number/date formatting.
max-height
prop: maxHeight
string—Scroll inside the table past this height, e.g. "28rem" (sticky header and footer). Rows that would overflow it by less than a wheel notch are shown whole instead (a sliver of inner scroll catches the wheel); not in the narrow card layout, where cards flow with the page.
persiststring—Save the user's view (columns, sort, filters) in localStorage under this key.
page-sizes
prop: pageSizes
number[]—Rows-per-page choices shown in the footer, e.g. [10, 25, 50].
srcstring—Server URL for rows; the query is added as parameters (or fills {placeholders}). Response: JSON. Implies manual.
rows-path
prop: rowsPath
string—Where the rows are in the response (dotted path; default: the response if it is an array, else rows, data or items).
total-path
prop: totalPath
string—Where the total row count is in the response (dotted path; default total, then count).
debouncenumber300Milliseconds to wait after typing in search or filters before asking the server.

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Events

EventReact / Svelte propDescription
pm-sortonPmSortThe sort order changed. detail.sorts is the whole sort order.
pm-filteronPmFilterSearch or column filters changed.
pm-selection-changeonPmSelectionChangeThe selected rows changed.
pm-pageonPmPageThe page or the page size changed.
pm-row-clickonPmRowClickA row was clicked (with row-clickable).
pm-expandonPmExpandA row's detail was opened or closed.
pm-cell-editonPmCellEditA cell was edited. Cancelable (call preventDefault to reject).
pm-state-changeonPmStateChangeColumn layout, sort or filters changed.
pm-column-resizeonPmColumnResizeA column was resized by its handle (key, width in px), to save it.
pm-loadonPmLoadServer rows arrived.
pm-load-erroronPmLoadErrorA server request failed.
pm-end-reachedonPmEndReachedScrolled near the bottom (load more rows). detail.rows is how many are loaded.

Slots

SlotDescription
emptyContent when there are no rows.
toolbarExtra content in the toolbar (filters, bulk actions).

Methods

reload(), resetColumns(), selectAllMatching(), clearSelection(), moveColumn(), pinColumn(), setColumnVisible(), pinRow(), toggleRow(), toCsv(), exportCsv()

Used in templates

Overview dashboardTraffic analyticsOrdersCustomer 360Project boardTeam and rolesBilling and invoices