Skip to content
Data 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 "@cooud-ui/ui";
bash
npx cooud-ui add data-table

Examples

API Reference

Generated from the component's exported types.

DataTableProps

PropTypeDefaultDescription
columns*
ColumnDef<TData, TValue>[]
data*
TData[]
searchable
booleanShow the toolbar with a global search field.
searchPlaceholder
stringPlaceholder for the global search field. Defaults to "Search…".
globalFilter
stringControlled 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
ReactNodeExtra nodes rendered on the left side of the toolbar.
toolbarEnd
ReactNodeExtra nodes rendered on the right side of the toolbar (before the View menu).
enableColumnVisibility
booleanShow the "View" menu that toggles column visibility.
columnVisibility
VisibilityStateControlled column visibility state.
onColumnVisibilityChange
OnChangeFn<VisibilityState>Called when column visibility changes.
sorting
SortingStateControlled sorting state.
onSortingChange
OnChangeFn<SortingState>Called when sorting changes.
manualSorting
booleanServer-side sorting: skip the client sort model.
columnFilters
ColumnFiltersStateControlled column filters state.
onColumnFiltersChange
OnChangeFn<ColumnFiltersState>Called when column filters change.
manualFiltering
booleanServer-side filtering: skip the client filter model.
pagination
booleanShow the pagination footer.
paginationState
PaginationStateControlled pagination state.
onPaginationChange
OnChangeFn<PaginationState>Called when pagination changes (controlled).
manualPagination
booleanServer-side pagination: provide `pageCount` or `rowCount`.
pageCount
numberTotal page count for server-side pagination.
rowCount
numberTotal row count for server-side pagination (used to derive `pageCount`).
initialPageSize
numberInitial 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
RowSelectionStateControlled row-selection state.
onRowSelectionChange
OnChangeFn<RowSelectionState>Called when row selection changes.
bulkActions
(rows: Row<TData>[]) => ReactNodeRender 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
DataTableDensityControlled 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) => voidCalled when the density toggle is pressed (controlled or uncontrolled).
initialDensity
DataTableDensityInitial density when uncontrolled. Defaults to "comfortable".
enableDensityToggle
booleanShow a comfortable/compact density toggle in the toolbar.
enableCsvExport
booleanShow a CSV export button in the toolbar.
csvFileName
stringDownload file name (without extension). Defaults to "export".
loading
booleanRender skeleton rows instead of data.
loadingRowCount
numberNumber of skeleton rows while `loading`. Defaults to the page size or 5.
error
ReactNodeRender an error state with an optional retry button.
onRetry
() => voidCalled when the error-state retry button is pressed.
emptyState
ReactNodeCustom empty-state content. Defaults to "No results.".
className
stringClass applied to the outer wrapper.
toolbarLabel
stringAccessible label for the toolbar region. Defaults to "Table controls".

DataTableColumnHeaderProps

PropTypeDefaultDescription
column*
Column<TData, TValue>
title*
string
className
string