Data Table
The table for records: sortable headers that report `aria-sort`, a global search, checkboxes with a bulk bar, a menu to hide columns, pagination and an empty state that offers to clear the search.
The decision inside it
Empty is not an error
A search with no matches says what was searched and offers 'Show everything', instead of a blank grid that looks broken.
Installation
How you get it
One command. The CLI writes the file into components/ui/ and installs what it needs.
npx shadcn@latest add https://layropro.com/r/data-tableAPI
“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Prop | Type | Notes |
|---|---|---|
datarequired | T[] | — |
columnsrequired | ColumnDef<T, any>[] | — |
searchPlaceholder | string | Show a search box that filters across every column. |
selectable | boolean | Adds a checkbox column. |
bulkActions | (rows: T[]) => React.ReactNode | Rendered in the toolbar while rows are selected. |
onSelectionChange | (rows: T[]) => void | — |
pageSize | number | Rows per page. 0 turns paging off. Default 10. |
columnToggle | boolean | Adds a columns menu for hiding and showing columns. |
getRowId | (row: T, index: number) => string | Stable row ids; defaults to the index. |
onRowClick | (row: T) => void | — |
density | "compact" | "comfortable" | — |
empty | React.ReactNode | — |
label | string | What the rows are, for the table's accessible name: "Invoices". |
className | string | — |
Dependencies
npm packages
@tanstack/react-tableclsxlucide-reacttailwind-mergeLayro foundations, installed alongside it
layro-themebuttoncheckboxdropdown-menuinputpaginationstateLifetime access
Every component, and everything we ship next.
- All 65 components, source included
- The template, and everything released after you buy
- shadcn CLI or download — React 18/19, Tailwind v4
- One payment. No subscription.