DataTable
Hybrid data table built on TanStack Table v9 and TanStack Virtual v3. Supports zero-boilerplate and composable APIs, sorting, faceted filtering, pagination, row selection, expandable rows, logical column pinning, column resizing, and 10k+ row virtualization.
Import
import {
DataTable,
DataTableColumnHeader,
createDataTableColumnHelper,
createSelectionColumn,
} from "@/components/ui/hacline/components/data-table";Zero-Boilerplate Mode
Omit children to automatically assemble the toolbar, selection bar, table content, and pagination bar from high-level props. Use createDataTableColumnHelper<TData>() for feature-gated TanStack Table v9 column inference.
| Status | ||||
|---|---|---|---|---|
Alice Chenalice@hacline.dev | Engineering | active | 14,820 | |
Bob Tanakabob@hacline.dev | Design | active | 8,420 | |
Carol Wucarol@hacline.dev | Product | invited | 4,210 | |
David Zhoudavid@hacline.dev | Engineering | suspended | 1,290 | |
Eva Lineva@hacline.dev | Engineering | active | 21,350 |
import { Button } from "@/components/ui/hacline/components/button";
import {
DataTable,
DataTableColumnHeader,
createDataTableColumnHelper,
createSelectionColumn,
} from "@/components/ui/hacline/components/data-table";
const columnHelper = createDataTableColumnHelper<Member>();
const columns = [
createSelectionColumn<Member>(),
...columnHelper.columns([
columnHelper.accessor("name", {
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Member" />
),
meta: { label: "Member" },
}),
columnHelper.accessor("department", {
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Department" />
),
}),
columnHelper.accessor("monthlyUsage", {
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Requests" />
),
meta: { align: "right", label: "Requests" },
}),
]),
];
export function MembersTable({ data }: { data: Member[] }) {
return (
<DataTable
columns={columns}
data={data}
enablePagination
getRowId={(row) => row.id}
searchable
selectionActions={(rows) => (
<Button size="sm" variant="outline">
Export ({rows.length})
</Button>
)}
showViewOptions
/>
);
}Composable Layout & Faceted Filters
Pass explicit children (DataTableToolbar, DataTableSearch, DataTableFacetedFilter, DataTableViewOptions, DataTableSelectionBar, DataTableContent, DataTablePagination) for full layout control. Pair DataTableFacetedFilter with the built-in filterFn: "inArray".
| Status | ||||
|---|---|---|---|---|
Alice Chenalice@hacline.dev | Engineering | active | 14,820 | |
Bob Tanakabob@hacline.dev | Design | active | 8,420 | |
Carol Wucarol@hacline.dev | Product | invited | 4,210 | |
David Zhoudavid@hacline.dev | Engineering | suspended | 1,290 | |
Eva Lineva@hacline.dev | Engineering | active | 21,350 |
import { Button } from "@/components/ui/hacline/components/button";
import {
DataTable,
DataTableContent,
DataTableEmpty,
DataTableFacetedFilter,
DataTablePagination,
DataTableSearch,
DataTableSelectionBar,
DataTableToolbar,
DataTableViewOptions,
} from "@/components/ui/hacline/components/data-table";
export function ComposableTable({ columns, data }) {
return (
<DataTable columns={columns} data={data} enablePagination striped>
<DataTableToolbar>
<div className="flex flex-1 flex-wrap items-center gap-2">
<DataTableSearch placeholder="Filter by name, email..." />
<DataTableFacetedFilter
columnId="status"
options={[
{ label: "Active", value: "active" },
{ label: "Invited", value: "invited" },
{ label: "Suspended", value: "suspended" },
]}
title="Status"
/>
</div>
<DataTableViewOptions />
</DataTableToolbar>
<DataTableSelectionBar>
{(selectedRows) => (
<Button size="sm" variant="danger">
Archive ({selectedRows.length})
</Button>
)}
</DataTableSelectionBar>
<DataTableContent
empty={<DataTableEmpty title="No matching members" />}
/>
<DataTablePagination showFirstLast />
</DataTable>
);
}Row Actions Column
Use createActionsColumn() (or DataTableRowActions inside custom cells) for per-row actions. Set maxInline={0} for a compact ⋯ dropdown menu, or maxInline >= 1 to keep primary actions inline while automatically folding remaining items into the overflow menu. Per-row hidden / disabled predicates, destructive styling, and redundant separator cleanup are handled automatically.
| Status | Actions | |||
|---|---|---|---|---|
Alice Chenalice@hacline.dev | Engineering | active | 14,820 | |
Bob Tanakabob@hacline.dev | Design | active | 8,420 | |
Carol Wucarol@hacline.dev | Product | invited | 4,210 | |
David Zhoudavid@hacline.dev | Engineering | suspended | 1,290 | |
Eva Lineva@hacline.dev | Engineering | active | 21,350 |
import {
DataTable,
createActionsColumn,
} from "@/components/ui/hacline/components/data-table";
const columns = [
...baseColumns,
createActionsColumn<Member>({
maxInline: 1,
actions: (row) => [
{ label: "Edit", onSelect: (r) => editMember(r.original) },
{
label: "Copy email",
shortcut: "⌘C",
onSelect: (r) => copy(r.original.email),
},
{ type: "separator" },
{
label: "Remove",
destructive: true,
disabled: row.original.role === "Admin",
onSelect: (r) => removeMember(r.original.id),
},
],
}),
];Expandable Rows & Tree Sub-Rows
Combine createExpandColumn() with getSubRows for indented hierarchical trees, or renderSubComponent for inline row detail panels.
| Unit | Owner | Headcount | Annual Budget | |
|---|---|---|---|---|
| Platform Engineering | Alice Chen | 14 | $820,000 | |
| UI Foundations | Eva Lin | 8 | $460,000 | |
| Edge Runtime | Iris Patel | 6 | $360,000 | |
| Product & Design | Bob Tanaka | 9 | $540,000 |
import {
DataTable,
createExpandColumn,
} from "@/components/ui/hacline/components/data-table";
const columns = [
createExpandColumn<OrgNode>({ showExpandAll: true }),
...baseColumns,
];
// Tree hierarchy
<DataTable
columns={columns}
data={orgTree}
getRowId={(row) => row.id}
getSubRows={(row) => row.subRows}
/>;
// Inline detail panel
<DataTable
columns={columns}
data={orgTree}
getRowId={(row) => row.id}
renderSubComponent={({ row }) => <div>{row.original.notes}</div>}
/>;Logical Column Pinning & Resizing
TanStack Table v9 uses logical start / end pinning regions (inset-inline-start / inset-inline-end) for automatic LTR and RTL support. Enable enableColumnResizing to drag column dividers or double-click a divider to reset width; use DataTableColumnHeader with mode="menu" to pin or hide columns interactively.
| Alice Chen | alice@hacline.dev | Engineering | Admin | us-west-2 | 2m ago | 14,820 | active |
| Bob Tanaka | bob@hacline.dev | Design | Editor | ap-northeast-1 | 14m ago | 8,420 | active |
| Carol Wu | carol@hacline.dev | Product | Editor | ap-southeast-1 | 1h ago | 4,210 | invited |
| David Zhou | david@hacline.dev | Engineering | Viewer | eu-central-1 | 3d ago | 1,290 | suspended |
| Eva Lin | eva@hacline.dev | Engineering | Admin | us-east-1 | Just now | 21,350 | active |
| Frank Park | frank@hacline.dev | Operations | Editor | ap-northeast-2 | 4h ago | 6,780 | active |
<DataTable
bordered
columns={pinningColumns}
data={members}
defaultColumnPinning={{ start: ["name"], end: ["status"] }}
enableColumnResizing
showViewOptions
/>Virtualized Large Datasets
Set virtualized and maxHeight to render 10,000+ rows smoothly using @tanstack/react-virtual v3 (configured with useFlushSync: false for React 19 compatibility).
Rendering 10,000 rows with @tanstack/react-virtual v3.
| ID | Endpoint | Status | Region | ||
|---|---|---|---|---|---|
| req-00001 | auth-api | /v1/tokens | 200 | 12 ms | us-east-1 |
| req-00002 | edge-gateway | /v1/orders | 200 | 49 ms | us-west-2 |
| req-00003 | billing-worker | /v1/query | 201 | 86 ms | eu-central-1 |
| req-00004 | search-index | /v1/webhooks | 429 | 123 ms | ap-northeast-1 |
| req-00005 | auth-api | /v1/tokens | 500 | 160 ms | us-east-1 |
| req-00006 | edge-gateway | /v1/orders | 200 | 197 ms | us-west-2 |
| req-00007 | billing-worker | /v1/query | 200 | 234 ms | eu-central-1 |
| req-00008 | search-index | /v1/webhooks | 201 | 271 ms | ap-northeast-1 |
| req-00009 | auth-api | /v1/tokens | 429 | 28 ms | us-east-1 |
| req-00010 | edge-gateway | /v1/orders | 500 | 65 ms | us-west-2 |
| req-00011 | billing-worker | /v1/query | 200 | 102 ms | eu-central-1 |
| req-00012 | search-index | /v1/webhooks | 200 | 139 ms | ap-northeast-1 |
| req-00013 | auth-api | /v1/tokens | 201 | 176 ms | us-east-1 |
| req-00014 | edge-gateway | /v1/orders | 429 | 213 ms | us-west-2 |
| req-00015 | billing-worker | /v1/query | 500 | 250 ms | eu-central-1 |
| req-00016 | search-index | /v1/webhooks | 200 | 287 ms | ap-northeast-1 |
| req-00017 | auth-api | /v1/tokens | 200 | 44 ms | us-east-1 |
| req-00018 | edge-gateway | /v1/orders | 201 | 81 ms | us-west-2 |
<DataTable
columns={metricColumns}
data={tenThousandRows}
density="compact"
maxHeight={340}
searchable
virtualized
/>Server-Side (Manual) Mode & Loading States
Enable manualSorting, manualFiltering, and manualPagination alongside controlled state props and rowCount. When loading is true, empty tables render aligned skeleton rows while populated tables display a non-blocking top progress bar.
| Status | |||
|---|---|---|---|
<DataTable
columns={columns}
data={pageRows}
enablePagination
globalFilter={query}
loading={loading}
manualFiltering
manualPagination
manualSorting
onGlobalFilterChange={setQuery}
onPaginationChange={setPagination}
onSortingChange={setSorting}
pagination={pagination}
rowCount={totalCount}
searchable
sorting={sorting}
/>Props
Prop
Type
Data Attributes
| Attribute | Description |
|---|---|
data-slot="data-table" | Root container element |
data-slot="data-table-toolbar" | Toolbar layout container |
data-slot="data-table-selection-bar" | Bulk selection action bar |
data-slot="data-table-content" | Scrollable table container (data-virtualized, data-loading) |
data-slot="data-table-pagination" | Pagination & page-size footer bar |
data-slot="table" | Semantic <table> primitive (data-density, data-striped, data-bordered, data-sticky-header) |
data-pinned="start" | "end" | Logical pinned column cells (data-last-pinned-start, data-first-pinned-end) |
data-resizing | Present on a column header and resize handle during drag |
data-selected | Present on selected body rows |
data-expanded | Present on expanded body rows and disclosure triggers |