shadcn-impl-data-table
Installation
SKILL.md
shadcn ui : DataTable Recipe (TanStack Table v8)
Deterministic mental model for the shadcn DataTable. There is NO DataTable primitive in shadcn. The official recipe (https://ui.shadcn.com/docs/components/radix/data-table) composes @tanstack/react-table v8 with the shadcn Table primitive. ALWAYS treat DataTable as a recipe-skill, not a primitive-skill : you write a reusable components/ui/data-table.tsx file in user space.
Quick Reference
One mental model
A DataTable is three concerns wired together :
- Schema : a
ColumnDef<TData, TValue>[]array describes columns (accessor + header + cell). - Headless engine :
useReactTable({ data, columns, getCoreRowModel, ... })returns atableinstance. - Markup : a
<DataTable />component renders the shadcn<Table>primitive driven bytable.getHeaderGroups()andtable.getRowModel().rows.
ALWAYS pass getCoreRowModel: getCoreRowModel() or the table renders ZERO rows. ALWAYS mark the DataTable component file "use client" ; the headless engine uses React hooks and breaks under server-rendering.