Skip to main content

Table

A styled, accessible data table with sortable headers and row activation. @startingPoint section="Data" subtitle="Sortable, selectable data table with density modes" viewport="760x320"

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When to use​

  • Use it when Straightforward, sortable tabular data without heavy interaction.
  • Reach for something else when Filtering, saved views or inline edit — use DataGrid.

Accessibility​

Rendered as a real <table> with header scopes; sortable columns expose aria-sort. Row selection and actions are keyboard reachable.

Install and import​

npx shadcn@latest add @prism/table
import { Table } from '@/components/prism/Table';

In a no-build prototype, read it from the bundle instead: const { Table } = window.PrismDesignSystem_39d121;

Props​

PropTypeRequiredDescription
columnsTableColumn[]Yes
rowsany[]Yes
rowKeystring—Field holding each row's key, e.g. "slug". Serializable, so it works from a server component. Default: row.id, else the index. The key must be plain text: if that field holds an element, the row falls back to its index.
getRowKey(row: any, index: number) =&gt; string | number—Function form of rowKey (client components only). Wins over rowKey.
captionReact.ReactNode—
density"comfortable" | "compact"—compact tightens padding for dense reports.
verticalAlign"top" | "middle"—"top" aligns every cell to the top (cells with a field plus a caption). Default middle.
hoverableboolean—
isStripedboolean—Subtle zebra striping. Default true.
isSelectableboolean—Show a checkbox column with select-all.
selectedKeys(string | number)[]—
onSelectionChange(keys: (string | number)[]) =&gt; void—
onRowAction(row: any) =&gt; void—Makes rows actionable. Each row gets a real <button> in its first column cell (visually hidden) for keyboard and screen-reader users; a click anywhere on the row runs it too. Client components only (it's a function).
rowLabelstring—Field holding each row's accessible name (its action button, expand toggle and checkbox), e.g. "name". Server-safe. Default: the first column's text.
getRowLabel(row: any) =&gt; string—Function form of rowLabel (client components only). Wins over rowLabel.
disabledKeys(string | number)[]—Keys of rows that can't be activated or selected. Server-safe. The row's action is aria-disabled (still focusable, announced as unavailable).
isRowDisabled(row: any) =&gt; boolean—Function form of disabledKeys (client components only).
headerGroupsTableHeaderGroup[]—Header bands spanning several columns, e.g. [{ label: "Fees", columns: ["setup", "perStudent"] }]. Renders a <th scope="colgroup"> band row above the column headers; ungrouped columns span both rows. A group split by other columns repeats its label over each run. Server-safe.
sortDescriptorSortDescriptor—
onSortChange(descriptor: SortDescriptor) =&gt; void—
rowTonestring—Field holding each row's tone ("negative" | "notice" | "positive"), e.g. "tone". Serializable, so it works from a server component. A toned row gets a tint and a leading edge bar (solid / dashed / thin by tone). Say why in a cell too (a Badge).
getRowTone(row: any) =&gt; TableRowTone | undefined | null—Function form of rowTone (client components only). Wins over rowTone.
renderDetail(row: any) =&gt; React.ReactNode—Detail panel for a row: adds a leading expand toggle and a full-width row under it. Client components only.
expandedKeys(string | number)[]—Controlled expanded row keys.
defaultExpandedKeys(string | number)[]—Initially expanded row keys (uncontrolled).
onExpandedChange(keys: (string | number)[]) =&gt; void—
classNamestring—