Skip to main content
The DataTable component is a powerful enterprise feature built on TanStack Table that provides sorting, filtering, pagination, column visibility, grouping, and virtualization out of the box.

Basic usage

Server-side mode

Use server-side mode for large datasets with backend pagination and filtering.

With virtualization

Use VirtualizedContent for rendering large datasets efficiently.

Column definitions

Define columns with rich configuration options.

Filtering

Enable column filters with various filter types.

Sorting

Enable sorting on columns.

Grouping

Group rows by a column value.

Column visibility

Control which columns are visible.

Custom empty states

Customize empty and zero states.

Row click handling

Handle row clicks for navigation or actions.

Using the useDataTable hook

Access table context from child components.

Infinite loading

Implement infinite scroll loading for server-side data.

Custom styling

Apply custom styles to table elements.

API reference

DataTable (root)

TData[]
required
Array of data objects to display in the table.
DataTableColumnDef<TData, TValue>[]
required
Column definitions for the table.
DataTableSort
required
Default sort configuration with name (column accessor) and order (‘asc’ | ‘desc’).
'client' | 'server'
default:"'client'"
Data fetching mode. Use ‘server’ for backend pagination and filtering.
DataTableQuery
Initial query state for filters, sorting, grouping, and pagination.
boolean
default:"false"
Whether data is currently loading.
number
default:"3"
Number of skeleton rows to show while loading.
(query: DataTableQuery) => void
Callback fired when the query changes (server mode only).
() => Promise<void>
Callback for infinite scroll loading (server mode only).
(row: TData) => void
Callback fired when a row is clicked.
(columnVisibility: VisibilityState) => void
Callback fired when column visibility changes.

DataTableColumnDef

string
required
Key to access the data in each row object.
string | ((props) => ReactNode)
required
Column header text or render function.
(props) => ReactNode
Custom cell render function.
boolean
Whether sorting is enabled for this column.
boolean
Whether filtering is enabled for this column.
boolean
Whether the column can be hidden.
boolean
Whether the column is hidden by default.
'text' | 'number' | 'select' | 'boolean' | 'date'
Type of filter input to use.
'string' | 'number' | 'boolean' | 'date'
Data type for type-specific filtering.
FilterSelectOption[]
Options for select-type filters. Each option has label and value.
boolean
Whether the column can be used for grouping.
boolean
Whether to show count badge in group headers.
Record<string, string>
Map of data values to display labels for group headers.
{ header?: string; cell?: string }
Custom CSS classes for header and cell elements.
{ header?: React.CSSProperties; cell?: React.CSSProperties }
Inline styles for header and cell elements.

DataTable.Content

ReactNode
Component to show when no data matches the current filters/search.
ReactNode
Component to show when there is no data and no filters are applied.
{ root?: string; table?: string; header?: string; body?: string; row?: string }
Custom CSS classes for various table elements.

DataTable.VirtualizedContent

Extends DataTable.Content props with additional virtualization options.
number
default:"40"
Height of each row in pixels.
number
Height of group header rows in pixels. Falls back to rowHeight if not set.
number
default:"5"
Number of rows to render outside the visible area for smooth scrolling.
number
default:"100"
Distance in pixels from bottom to trigger onLoadMore.

DataTable.Toolbar

Container for toolbar elements like search, filters, and display controls.
ReactNode
required
Toolbar content.
string
Placeholder text for the search input.

DataTable.Filters

Renders filter controls for columns with enableColumnFilter: true.

DataTable.DisplayControls

Renders column visibility controls and other display settings.

useDataTable hook

Hook to access the data table context from child components. Returns:
Table<TData>
TanStack Table instance with full API access.
DataTableColumnDef<TData, TValue>[]
Column definitions.
InternalQuery
Current table query state including filters, sorting, and pagination.
(fn: (query: InternalQuery) => InternalQuery) => void
Function to update the table query.
'client' | 'server'
Current data fetching mode.
boolean
Whether data is currently loading.
() => void
Function to reset display settings to defaults.