Components / Data
Data Table
A TanStack table shell: column pinning, drag-to-reorder, a selection rail and skeleton rows.
Install — needs @hiip registered in components.json
bunx shadcn@latest add @hiip/data-tableOr by URL, with the token in the query
bunx shadcn@latest add "https://ui.hiip.ai/r/data-table.json?token=$HIIP_REGISTRY_TOKEN"Both need a token — set one up.
Anatomy
Import from components/ui/hiip-ui/data-table.
<DataTable
table={…} // a TanStack table instance the CALLER builds
rowKey={…}
emptyTitle="…"
emptyHint="…"
/>Examples
| Mai Khanh | tiktok | Negotiating |
| Duy Anh | Replied | |
| Nurul | viber | Closed |
function DataTableDemo() {
// The shell renders a sort control for every column that CAN sort, so the
// caller owes it a sorted row model and somewhere to keep the state — with
// neither, the header is a button that does nothing.
const [sorting, setSorting] = useState<SortingState>([]);
const table = useReactTable({
data: DEMO_ROWS,
columns: DEMO_COLUMNS,
state: { sorting },
onSortingChange: setSorting,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
});
return (
<div className="w-full">
<DataTable
table={table}
rowKey={(r) => r.creator}
emptyTitle="No creators"
emptyHint="Import a sheet to get started."
emptyIcon={Album02Icon}
footerLabel={`${DEMO_ROWS.length} creators`}
autoHeight
/>
</div>
);
}API Reference
Generated from the source. Props forwarded to the underlying element are not listed.
DataTable
The app's data-table shell: a `@tanstack/react-table` instance rendered through this repo's own `ui/table` primitives.
| Prop | Type | Default |
|---|---|---|
emptyHintrequired | string | — |
emptyIconrequired | IconSvgElement | — |
emptyTitlerequired | string | — |
footerLabelrequiredLeft side of the pager, e.g. "12 of 40 creators". | ReactNode | — |
rowKeyrequiredStable row key — the index is not one once sorting moves rows around. | (row: Row) => string | number | — |
tablerequired | Table<Row> | — |
autoHeightSize the box to its ROWS instead of filling the space its parent gives it. | boolean | undefined | — |
className | string | undefined | — |
columnRulesDraw a hairline between every column — see `COLUMN_RULE`. | boolean | undefined | — |
disabledFreeze the PAGER while the page is busy — a load in flight, or a write that will change what is on the page. | boolean | undefined | — |
errorA load FAILURE, never "nothing matched" — see the note on the error row below. | string | null | undefined | — |
isLoading | boolean | undefined | — |
manualPagerServer-cursor pagination: the caller owns both edges, and the TOTAL IS UNKNOWN. | { pageIndex: number; hasNextPage: boolean; onPrevious: () => void; onNext: () => void; } | undefined | — |
onRowClick | ((row: Row) => void) | undefined | — |
pinnedThroughHow far the frozen run reaches — the id of the LAST pinned column. | string | null | undefined | — |
DataTableColumnsMenu
The Columns control: which columns are drawn, in what ORDER, and how far the freeze reaches.
| Prop | Type | Default |
|---|---|---|
tablerequired | Table<Row> | — |
pinningOmit and the panel is show/hide + reorder only, with no freeze controls. | DataTablePinning | undefined | — |
- Type
registry:ui- Pulls in
- button, checkbox, popover, skeleton, tableshadcn installs these for you if they are missing.
- npm packages
@tanstack/react-table @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities @hugeicons/react @hugeicons/core-free-icons- Files written
- components/ui/hiip-ui/data-table.tsx