Skip to content
GitHub (opens in a new tab)

DataTable

Framed dataset with search, filters, column settings, and a caption title.

stableOrganismcontracts/datatable.json

Preview

DataTable

Responsive structured data with search, filters, column settings, and clear empty states.

Master

Small cells. Actions is kit Cell type=actionMenu. Table stays the short static list.

Showing 5 of 5

Team members
Actions
Maya ChenProduct designerActive8
Noah WilliamsEngineerActive5
Iris OkaforProduct managerActive3
Jordan LeeDesignerAway6
Alex RiveraEngineerActive4

Usage

DataTable for searchable datasets. Table for a short static list. Each td is a kit Cell. Compose Avatar or Badge in a cell when the row needs them.

Do's

  • Searchable datasets with filters or column settings
  • Selectable rows of structured data
  • A sortable table inside a Card (Card flush; DataTable drops its frame)

Don'ts

  • A short static list — use Table
  • Dashboard or list-detail activity lists — use Table
  • Editable cells — use DataGrid
<DataTable
  caption="Team members"
  selectable
  toolbar
  cellSize="sm"
  searchPlaceholder="Search members..."
  filters={[
    { key: "status", label: "Status" },
    { key: "role", label: "Role" },
  ]}
  columnSettings
  bulkActions={[
    { id: "export", label: "Export", appearance: "outline", mode: "neutral", iconStart: "Download", onClick: onExport },
    { id: "delete", label: "Delete", appearance: "solid", mode: "danger", iconStart: "Trash2", onClick: onDelete },
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "role", header: "Role" },
    { key: "status", header: "Status" },
    { key: "projects", header: "Projects", type: "number" },
    { key: "actions", header: "Actions" },
  ]}
  rows={[
    {
      name: "Maya Chen",
      role: "Product designer",
      status: "Active",
      projects: 8,
      actions: {
        type: "actionMenu",
        label: "Row actions",
        actions: [
          { label: "Edit", icon: "Pencil" },
          { label: "Make a copy", icon: "Copy" },
          { label: "Delete", icon: "Trash2", appearance: "solid", mode: "danger" },
        ],
      },
    },
  ]}
/>

When to use

  • Searchable datasets with filters or column settings
  • Selectable rows of structured data
  • A sortable table inside a Card (Card flush; DataTable drops its frame)

When not to use

  • A short static list — use Table
  • Dashboard or list-detail activity lists — use Table
  • Editable cells — use DataGrid

What an agent reads

import { DataTable } from "agentic-ds-kit";
must
  • table + thead th scope=col
  • caption element when set
  • search input aria-label from searchPlaceholder
  • filter DropdownMenu ariaLabel = filter label
  • Columns button aria-expanded / aria-haspopup
  • Row checkboxes ariaLabel like Select Maya Chen; header Select all rows
  • sortable th aria-sort none | ascending | descending
  • Narrow container keeps column min-width and scrolls horizontally; the scroller is a focusable region
  • Narrow container: search full width when filters are present; filter buttons share the row width; Columns stays start-aligned; toolbar actions are not in a horizontal scroller
  • The filter DropdownMenu trigger is the selected value; when any facet is set, Reset filters is a tertiary kit Button after the filter menus
  • When rows are selected, a selection row names the count, kit bulk action Buttons, and Clear selection
  • Without caption, ariaLabel names the table and the scroll region
  • Link cells are real links (Cell type=link) and stay focusable inside rows
defaults
  • selectable false
  • toolbar false
  • searchPlaceholder Search...
  • cellSize md
  • emptyMessage No results.
  • errorMessage Couldn’t load this table.
stops if
  • Do not use a native select for filters — use kit DropdownMenu
  • Do not wrap search in Field — DataTable owns its input
  • A row of filter chips is FilterBar. Do not invent ColumnPicker, Pagination, or a second Table
  • Editable in-place rows — use DataGrid
  • Do not invent a local Cell, DataTableCell, HeaderCell, Tag, Trend, FileIcon, or PaymentMethod — use Cell and HeaderCell (kit Tag is fine for user labels)
  • Do not use TanStack Table, cmdk, Storybook, Figma, or extra dependencies
  • Do not use raw hex
  • Do not put a checkbox on every Cell — row selection stays on DataTable
  • Do not add pagination (Pagination sits below the table), loading or row actions here — Table has state and rowActions; no expandable rows, sticky header, density, or infinite scroll
  • Do not invent FilterChip, a Tag-based filter summary, or a second filter summary — the dropdown trigger is the selected value; Reset filters and selection actions are kit Button
  • Do not put a primary Button in bulkActions
  • Do not invent a SortButton or use TanStack Table for sort
  • Do not squash columns to the container — overflow-x on the scroller; to fit a narrow container, set width on the short columns and wrap on the columns that can wrap
  • Do not put toolbar actions in a horizontal scroller — search full width, filter buttons fill the row, Columns stays start-aligned
  • Do not sort currency or date strings lexically — give the column sortValue

From contracts/datatable.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
captionstringNo——
ariaLabelstringNo—Names the table and its scroll region when there is no caption, e.g. inside a titled flush Card
selectablebooleanNofalse—
toolbarbooleanNofalseWhen true, show search + filters + optional Columns
searchPlaceholderstringNoSearch...—
filtersarrayNo—Each is a kit DropdownMenu of unique values from that column on the full rows, plus All {label}. Not a native select.
columnSettingsbooleanNo—Columns button; kit Checkboxes to show/hide columns. Name (or first data column) cannot be hidden. Local state only.
cellSizesm | mdNomdPassed to every Cell and HeaderCell. Inside a flush Card, the first and last columns take the card's inline padding instead (any card size, any cellSize), so they line up with the card header.
columnsarrayYes—type number right-aligns cell and header. sortable adds HeaderCell sort (asc, desc, then off). Local state only. sortValue returns what to sort by (numbers and Dates compare numerically, strings locale-aware): use it for currency strings and formatted dates; without it, sort is unchanged. sortValue is a function, so build the columns in a client component ("use client"), not a Server Component. Keep the raw value on the row under a key that is not a column (rows render only column keys). width / minWidth are CSS lengths on th and td. Text columns without either keep the default minimum (layout.metricsMin). width alone drops that minimum: the column takes the width but never gets narrower than its content (header label + sort icon, or the widest cell). minWidth replaces the minimum explicitly. wrap lets that column's cells and header label wrap (the sort icon stays with the last word) and makes the table fit its container; it still scrolls when the columns cannot fit. To fit a narrow container, give the short columns (ids, dates, badges) a width and set wrap on a text column; minWidth is not needed.
rowsarrayYes—Values may be Cell objects (type + fields) or plain string/number (rendered as Cell type=text). Optional row.id if primitive; skip object ids.
emptyMessagestringNoNo results.—
stateloading | empty | errorNo—Same as Table. loading: header stays, rows are Skeleton bars, table aria-busy. empty: a small Empty with emptyMessage. error: LoadError with errorMessage and onRetry. Without state, rows render (and no rows is empty).
errorMessagestringNoCouldn’t load this table.state error: what failed, named, like Couldn’t load invoices.
onRetryfunctionNo—() => void. state error: shows the Try again Button.
onSelectionChangefunctionNo—(ids: string[]) => void
bulkActionsarrayNo—Shown when selectable and at least one row is checked. kit Buttons. Never solid-primary.
  • Component
    →

    Table

    Simple semantic table for invoices, lists, and text rows, with optional sort, row menu, sticky header, loading, empty and error states, row dividers on or off, and one optional highlighted row.

  • Component
    →

    DataGrid

    An editable table: people click a cell to add or change its content, like rule conditions, line items, or mappings.

  • Component
    →

    Cell

    Inline cell content for datasets: text, link, avatar, file, payment, badge, trend, avatar group, select, progress, rating, or row actions, with optional checkbox.

  • Component
    →

    HeaderCell

    Column header for DataTable: label, optional select-all checkbox, optional sort, sm or md.