Data Table
Generic data-driven table built on TanStack Table + Hex UI Table primitives. Pass columns + data; add sorting/filtering/pagination via TanStack hooks.
| Status | Amount | |
|---|---|---|
success | ken99@yahoo.com | $316.00 |
success | abe45@gmail.com | $242.00 |
processing | monserrat44@yahoo.com | $837.00 |
success | silas22@hotmail.com | $874.00 |
failed | carmella@qmail.com | $721.00 |
Installation
pnpm dlx @hex-core/cli add data-tableAPI Reference
| Prop | Type | Default | Description |
|---|---|---|---|
columnsrequired | object | — | ColumnDef<TData, TValue>[] from @tanstack/react-table |
datarequired | object | — | Array of row data |
AI Guidance
When to use
Use for tabular data that needs sorting, filtering, pagination, or row selection. Define columns once, feed data — TanStack handles the row model. Add more features incrementally (getSortedRowModel, getFilteredRowModel, getPaginationRowModel).
When not to use
Don't use for static/simple tables (use Table primitives directly). Don't use for virtualized very-large lists (use TanStack Virtual). Don't use for grid layouts (use CSS grid). DataTable is a Client Component (uses useReactTable hook) — fetch data in a Server Component and pass it as props.
Common mistakes
- Forgetting getCoreRowModel() (table renders nothing)
- Recreating columns array on every render (breaks memoization — wrap in useMemo or define outside the component)
- Using accessorKey with nested paths without accessorFn
- Not adding filter/sort row models when those features are needed
Accessibility
Uses semantic <table> via Hex UI Table primitives. Add aria-sort to sortable column headers. Announce filter/sort changes via aria-live for dynamic updates.
Related components
Token budget: 900