DataTable
proDataTable pairs TanStack Table with the product Table primitives so sorting, selection, and paging arrive already wired.
Installation
Add this component with the NateUI CLI.
Examples
Sorting
- 1
Row Selection
- 1
Column Resizing
- 1
Pinned Columns
- 1
Expandable Rows
- 1
Drag And Drop
- 1
Empty State
API
DataTable wraps TanStack Table - columns,
Row<T>, and the render prop's table instance all come directly from that
library; see its own docs for the full column-def and table-instance API.
Sorting and pagination stay manual: DataTable expects data to already be
sorted and sliced to the current page, then calls back through onSort /
onPaginationChange / onPageSizeChange so a parent can re-sort or re-fetch.
Column resizing and sticky column pinning are built into the default renderer
when columnResize or columnPinning is enabled. Pass children only when
you need to replace the table structure entirely, as the Drag And Drop example
does. With overflow enabled, the default renderer uses NateUI Scroll for
horizontal table scrolling and applies overflowClass to its root; set
overflow={false} to render without that viewport. Pagination stays outside
the scroll region.
| Prop | Description | Type | Default |
|---|---|---|---|
columns | Column definitions for the table. | ColumnDef<T>[] | [] |
data | Rows to render for the current page. | T[] | [] |
loading | Shows skeleton rows while empty, or dims the table when rows are already present. | boolean | false |
noData | Renders the built-in empty state instead of rows. | boolean | false |
renderEmptyState | Replaces the default empty-state content. | ReactNode | - |
selectable | Adds a checkbox column for row and select-all selection. | boolean | false |
onRowSelect | Called when a single row's checkbox changes. | (checked: boolean, row: T) => void | - |
onAllRowSelect | Called when the header select-all checkbox changes. | (checked: boolean, rows: Row<T>[]) => void | - |
checkboxChecked | Overrides a row's checked state instead of TanStack's internal selection. | (row: T) => boolean | - |
indeterminateCheckboxChecked | Overrides the header checkbox's checked state. | (rows: Row<T>[]) => boolean | - |
onSort | Called when the sorted column or direction changes. | (sort: OnSortParam) => void | - |
columnPinning | Pins columns at the logical start or end by column id and renders them sticky in the default table. | ColumnPinningState | - |
columnResize | Adds resize handles to header cells. Pass { mode: 'onChange' } for live resizing while dragging. | boolean | ColumnResizeConfig | false |
pagingData | Current page, page size, and total row count. | { total: number; pageIndex: number; pageSize: number } | { total: 0, pageIndex: 1, pageSize: 10 } |
onPaginationChange | Called when the page changes. | (page: number) => void | - |
pageSizes | Options shown in the page-size select. | number[] | [10, 25, 50, 100] |
onPageSizeChange | Called when the page-size select changes. | (size: number) => void | - |
skeletonAvatarColumns | Column indexes that render an avatar-shaped skeleton while loading. | number[] | - |
skeletonAvatarProps | Props for those skeleton avatars. | SkeletonProps | - |
children | Renders the table body yourself from the underlying TanStack instance, instead of DataTable's default rows. | (props: { table: Table<T> }) => ReactNode | - |
ref | Exposes resetSorting() and resetSelected(). | Ref<DataTableResetHandle> | - |
...tableProps | Forwarded to the underlying Table, for example bordered, compact, or overflow. | TableProps | - |