Sortable data table
Compare structured records with sortable columns.
npx shadcn@latest add @silicon-ui/sortable-data-tableInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/sortable-data-tableManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/sortable-data-table/sortable-data-table.tsx
- components/silicon-ui/sortable-data-table/sortable-data-table.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
rows* | T[] | — |
columns* | DataColumn<T>[] | — |
rowKey* | keyof T | ((row: T) => string) | — |
caption | string | "Data table" |
emptyMessage | string | "No rows to show" |
defaultSortSort applied on the first render. | SortState | — |
onSortChange | (sort: SortState) => void | — |
selectableAdds a checkbox column, row click selection, and a count line with a clear action. | boolean | false |
selectedKeys | string[] | — |
defaultSelectedKeys | string[] | — |
onSelectionChange | (keys: string[]) => void | — |
itemNameNoun for the count line, as in "6 projects". | { one: string; other: string } | { one: "row", other: "rows" } |
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens