Data Table
Data displayDisplays records with client-side filtering, sortable columns, and paginated rows.
Try it
Add to your project
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/data-table.jsonThe command includes the component’s shared dependencies. Your project keeps editable source files.
Include the complete example
This example also composes badge, typography. Install its parts together:
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/data-table.json https://luv-jeri.github.io/cojeev-ui/r/badge.json https://luv-jeri.github.io/cojeev-ui/r/typography.jsonUsing data table
Pass data and column definitions; provide sortValue only for columns that should sort.
Add predicate filters, set pageSize, and use page or filter callbacks when application state must track the view.
API
Compose the exported parts below. The prop types are read from the React source during the registry build.
Native element or underlying primitive props are inherited where declared, including accessible labels, event handlers and refs.
DataTableProps
| Prop | Type | Required |
|---|---|---|
data | T[] | Yes |
columns | DataTableColumn<T>[] | Yes |
getRowIdThe index is the row's position in data, before filtering or sorting. | (row: T, index: number) => string | No |
filters | DataTableFilter<T>[] | No |
filter | string | No |
defaultFilter | string | No |
onFilterChange | (filter: string) => void | No |
page | number | No |
defaultPage | number | No |
onPageChange | (page: number) => void | No |
pageSize | number | No |
emptyMessage | React.ReactNode | No |
caption | string | No |
onRowClick | (row: T) => void | No |
DataTableViewportProps
Accepts the native or primitive props declared by its exported TypeScript type.
DataTableFiltersProps
Accepts the native or primitive props declared by its exported TypeScript type.
DataTableFilterButtonProps
| Prop | Type | Required |
|---|---|---|
pressed | boolean | No |
DataTablePaginationProps
Accepts the native or primitive props declared by its exported TypeScript type.
DataTableEmptyProps
Accepts the native or primitive props declared by its exported TypeScript type.
Accessibility
Supply a caption and clear column headers; sortable headers expose their direction with aria-sort.
For important row actions, include clearly named controls in cells even when onRowClick is also available.
States and appearance
For conditional content, keep a MotionPresence boundary around keyed MotionSurface children. The shared entrance and exit states work with native primitives and respect your motion preference.
Try pointer and keyboard interaction, and switch the appearance control in the navigation to compare light and dark mode. Motion respects reduced motion preferences.