Data Table

Table of your data on TanStack Table v8, with sorting, pagination, filtering, row selection, column visibility and cell helpers.

import { DataTable, DataTableColumnHeader } from "@plexui/ui/components/DataTable";

For plain markup tables, use Table: Data Table draws its rows with its parts.

The examples import users (15 rows) and its User type from a local ./data file. Header and cell renderers are functions that return JSX, rendered with TanStack Table's flexRender.

Examples

Overview

variant
emptyMessage
RoleDepartmentStatus
Lindsay WaltonFront-end DeveloperEngineering
Active
Courtney HenryDesignerDesign
Active
Tom CookDirector of ProductProduct
Active
Whitney FrancisCopywriterMarketing
Inactive
Leonard KrasnerSenior DeveloperEngineering
Active
Floyd MilesUX ResearcherDesign
Active

Sorting

Alicia BellProduct ManagerActive
Anna RobertsBackend DeveloperActive
Benjamin RusselDevOps EngineerActive
Courtney HenryDesignerActive
Emily SelmanVP MarketingActive
Rows per page
1–5 of 15

Pagination

IDNameDepartmentStatus
USR-001Lindsay WaltonEngineeringActive
USR-002Courtney HenryDesignActive
USR-003Tom CookProductActive
USR-004Whitney FrancisMarketingInactive
USR-005Leonard KrasnerEngineeringActive
Rows per page
1–5 of 15

Row click

EmailRole
Lindsay Waltonlindsay@example.comFront-end Developer
Courtney Henrycourtney@example.comDesigner
Tom Cooktom@example.comDirector of Product
Whitney Franciswhitney@example.comCopywriter
Rows per page
1–4 of 8

Click a row to see selected user details.

Row selection

RoleStatus
Lindsay WaltonFront-end Developer
Active
Courtney HenryDesigner
Active
Tom CookDirector of Product
Active
Whitney FrancisCopywriter
Inactive
Leonard KrasnerSenior Developer
Active
Rows per page
1–5 of 15

0 of 15 rows selected

Cell variants

IDNameStatusJoinedSalary
USR-001Lindsay Walton
Active
Jan 15, 2023, 09:00 AM$95,000
USR-002Courtney Henry
Active
Mar 22, 2023, 09:00 AM$88,000
USR-003Tom Cook
Active
Jun 10, 2022, 09:00 AM$120,000
USR-004Whitney Francis
Inactive
Jul 4, 2023, 09:00 AM$72,000
USR-005Leonard Krasner
Active
Feb 18, 2022, 09:00 AM$115,000
USR-006Floyd Miles
Active
May 11, 2023, 09:00 AM$85,000
Rows per page
1–6 of 15

Filtering

RoleDepartmentStatus
Lindsay WaltonFront-end DeveloperEngineering
Active
Courtney HenryDesignerDesign
Active
Tom CookDirector of ProductProduct
Active
Whitney FrancisCopywriterMarketing
Inactive
Leonard KrasnerSenior DeveloperEngineering
Active
Rows per page
1–5 of 15

Column visibility

RoleDepartmentStatusSalary
Lindsay WaltonFront-end DeveloperEngineering
Active
$95,000
Courtney HenryDesignerDesign
Active
$88,000
Tom CookDirector of ProductProduct
Active
$120,000
Whitney FrancisCopywriterMarketing
Inactive
$72,000
Leonard KrasnerSenior DeveloperEngineering
Active
$115,000
Rows per page
1–5 of 15

API

DataTable

PropTypeDefaultDescription
columnsColumnDef<TData>[]—Column definitions following TanStack Table v8 API (required)
dataTData[]—Data array to display (required)
variant"default" | "bordered""default"Visual variant: bordered adds a rounded border and tinted header
pageSizenumber10Rows per page. Set 0 or Infinity to disable pagination. The rows-per-page select offers 10, 20, 50, 100 and this size
initialSortingSortingState—Initial column sorting state
globalFilterstring—Controlled search/filter string
onGlobalFilterChange(value: string) => void—Callback when filter changes
onRowClick(row: TData) => void—Click handler for rows. Makes rows interactive: they take Tab and call it on Enter or Space
columnVisibilityVisibilityState—Controlled column visibility state
onColumnVisibilityChange(visibility: VisibilityState) => void—Callback when visibility changes
enableRowSelectionbooleanfalseAdds a first column (id select) with a checkbox per row and a header checkbox that selects every row on all pages, mixed when some are selected. A click on a checkbox is not a row click
rowSelectionRowSelectionState—Controlled row selection state
onRowSelectionChange(selection: RowSelectionState) => void—Callback when selection changes
getRowId(row: TData) => string—Custom row ID accessor; selection keys use it
emptyMessageReactNode"No results."Shown when no rows
showPaginationbooleantrueWhether to show pagination controls. They hide on their own when every row fits on one page
classNamestring—Class applied to outermost wrapper

Column groups (a column definition with columns) render a header that spans its columns.

DataTableColumnHeader

PropTypeDefaultDescription
columnColumn<TData, TValue>—TanStack Table column object (required)
titlestring—Display text for the header (required)
classNamestring—Class applied to the header button (or text when the column cannot sort)

Column helpers

PropTypeDefaultDescription
idCell(accessor)CellComponent—Monospace ID with copy-on-click tooltip
dateTimeCell(accessor, options?)CellComponent—Formatted datetime with Intl.DateTimeFormat in the reader's time zone. It hydrates without a mismatch: the server writes the time in UTC (or in the timeZone of the options), and the reader's zone and wording follow once the page is in the browser. An ISO date or time written without a zone (2023-01-15, 2023-01-15T09:00) shows as written in every zone; a value that is no date shows as it is
statusCell(accessor, colorMap?)CellComponent—Badge cell with automatic status-to-color mapping
tooltipHeader(label, description)HeaderComponent—Header with dashed underline and info tooltip

Styling

Data Table draws its rows with the parts of Table, so it reads the tokens of Table › Styling.