Skip to content
Display

Data Table

TanStack table with sorting, search & faceted filters, pagination, row selection with bulk actions, column visibility, density, and loading/empty/error states.

Import

tsx
import { DataTable } from "@cronus-ui/ui";
bash
npx cronus-ui add data-table

Examples

.cronus

The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.

PortedParity: MatchGeometry 1/1Pixel diff 0 pxLogic 1/1Parity scoreboard
default.cronus
app "audit-fixtures" {
  port 5176
}

style {
  preset aurora
  theme dark
}

component DataTableDefault layout:inline style:data-table {
  label "Members"
  text "Name"
  text "Role"
  text "Ada"
  text "Admin"
  text "Linus"
  text "Editor"
}

page "/audit/data-table/default" type:custom {
  use DataTableDefault
}

API Reference

Generated from the component's exported types.

DataTableProps

Skip DataTableProps props table
PropTypeDefaultDescription
columns*
ColumnDef<TData, TValue>[]——
data*
TData[]——
searchable
boolean—Show the toolbar with a global search field.
searchPlaceholder
string—Placeholder for the global search field. Defaults to "Search…".
globalFilter
string—Controlled global filter value. Implies a controlled toolbar search.
onGlobalFilterChange
OnChangeFn<string>—Called when the global filter changes (controlled or uncontrolled).
facetedFilters
DataTableFacetedFilter[]—Faceted (multi-select) column filters rendered in the toolbar.
toolbarStart
ReactNode—Extra nodes rendered on the left side of the toolbar.
toolbarEnd
ReactNode—Extra nodes rendered on the right side of the toolbar (before the View menu).
enableColumnVisibility
boolean—Show the "View" menu that toggles column visibility.
columnVisibility
VisibilityState—Controlled column visibility state.
onColumnVisibilityChange
OnChangeFn<VisibilityState>—Called when column visibility changes.
sorting
SortingState—Controlled sorting state.
onSortingChange
OnChangeFn<SortingState>—Called when sorting changes.
manualSorting
boolean—Server-side sorting: skip the client sort model.
columnFilters
ColumnFiltersState—Controlled column filters state.
onColumnFiltersChange
OnChangeFn<ColumnFiltersState>—Called when column filters change.
manualFiltering
boolean—Server-side filtering: skip the client filter model.
pagination
boolean—Show the pagination footer.
paginationState
PaginationState—Controlled pagination state.
onPaginationChange
OnChangeFn<PaginationState>—Called when pagination changes (controlled).
manualPagination
boolean—Server-side pagination: provide `pageCount` or `rowCount`.
pageCount
number—Total page count for server-side pagination.
rowCount
number—Total row count for server-side pagination (used to derive `pageCount`).
initialPageSize
number—Initial page size when uncontrolled. Defaults to 10.
pageSizeOptions
number[]—Page-size options offered in the footer select. Defaults to [10, 20, 30, 50].
enableRowSelection
boolean | ((row: Row<TData>) => boolean)—Render a leading checkbox column with header select-all.
rowSelection
RowSelectionState—Controlled row-selection state.
onRowSelectionChange
OnChangeFn<RowSelectionState>—Called when row selection changes.
bulkActions
(rows: Row<TData>[]) => ReactNode—Render slot for bulk actions. Receives the currently selected rows; shown in a bar above the table only while at least one row is selected.
density
DataTableDensity—Controlled cell padding density. When provided, the toolbar toggle becomes controlled and you must update it via . Omit it to let the table manage density internally (see ).
onDensityChange
(density: DataTableDensity) => void—Called when the density toggle is pressed (controlled or uncontrolled).
initialDensity
DataTableDensity—Initial density when uncontrolled. Defaults to "comfortable".
enableDensityToggle
boolean—Show a comfortable/compact density toggle in the toolbar.
enableCsvExport
boolean—Show a CSV export button in the toolbar.
csvFileName
string—Download file name (without extension). Defaults to "export".
loading
boolean—Render skeleton rows instead of data.
loadingRowCount
number—Number of skeleton rows while `loading`. Defaults to the page size or 5.
error
ReactNode—Render an error state with an optional retry button.
onRetry
() => void—Called when the error-state retry button is pressed.
emptyState
ReactNode—Custom empty-state content. Defaults to "No results.".
className
string—Class applied to the outer wrapper.
toolbarLabel
string—Accessible label for the toolbar region. Defaults to "Table controls".
labels
Partial<DataTableLabels>—Override any subset of the built-in UI strings (selection checkbox labels, pagination, empty/loading/retry states…) for localization. Defaults are English; see .
getRowLabel
(row: Row<TData>) => string—Accessible name for each row-selection checkbox, built from the row data (e.g. `(row) => "Select " + row.original.name`). Takes precedence over `labels.selectRow`. Only applies to the selection column injected by `enableRowSelection`.

DataTableLabels

Skip DataTableLabels props table
PropTypeDefaultDescription
selectAllRows*
string—`aria-label` of the header select-all checkbox.
selectRow*
(rowIndex: number) => string—`aria-label` of a row checkbox. Receives the zero-based row index.
reset*
string—Toolbar button that clears all active filters.
densityComfortable*
string—Density toggle caption while compact (activating restores comfortable).
densityCompact*
string—Density toggle caption while comfortable (activating switches to compact).
exportCsv*
string—Toolbar CSV export button.
view*
string—Column-visibility menu trigger.
toggleColumns*
string—Column-visibility menu heading.
clearFilter*
string—Faceted-filter menu item that clears that filter.
bulkActions*
string—`aria-label` of the bulk-actions bar.
selectedCount*
(count: number) => string—Bulk-bar summary, e.g. "3 selected".
selectedOfTotal*
(selected: number, total: number) => string—Selection summary under the table, e.g. "1 of 3 row(s) selected."
rowsPerPage*
string—Label of the page-size select.
rowRange*
(first: number, last: number, total: number) => string—Visible row range, e.g. "1–10 of 42".
pageOf*
(page: number, pageCount: number) => string—Page position, e.g. "Page 2 of 5".
pagination*
string—`aria-label` of the pagination nav.
firstPage*
string—`aria-label` of the first-page button.
previousPage*
string—`aria-label` of the previous-page button.
nextPage*
string—`aria-label` of the next-page button.
lastPage*
string—`aria-label` of the last-page button.
noResults*
string—Default empty-state message (a custom `emptyState` node wins).
retry*
string—Error-state retry button.
loadingRows*
string—Polite screen-reader announcement while `loading`.

DataTableColumnHeaderLabels

Skip DataTableColumnHeaderLabels props table
PropTypeDefaultDescription
sort*
(title: string) => string—Unsorted — activation sorts ascending.
sortedAscending*
(title: string) => string—Sorted ascending — activation sorts descending.
sortedDescending*
(title: string) => string—Sorted descending — activation re-sorts ascending (never clears).

DataTableColumnHeaderProps

Skip DataTableColumnHeaderProps props table
PropTypeDefaultDescription
column*
Column<TData, TValue>——
title*
string——
className
string—Additional class names merged onto the root.
labels
Partial<DataTableColumnHeaderLabels>—Localize the sort-button `aria-label`s. See .