Skip to content
Cojeev UI

Data Table

Data display

Displays records with client-side filtering, sortable columns, and paginated rows.

React · copy into your project · light and dark themes

Try it

Loading preview…

Take it with you

Copy the example, API and usage notes for your editor or AI assistant.

Add to your project

Terminal
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/data-table.json

The 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:

Terminal
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.json

Using 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

PropTypeRequired
dataT[]Yes
columnsDataTableColumn<T>[]Yes
getRowId

The index is the row's position in data, before filtering or sorting.

(row: T, index: number) => stringNo
filtersDataTableFilter<T>[]No
filterstringNo
defaultFilterstringNo
onFilterChange(filter: string) => voidNo
pagenumberNo
defaultPagenumberNo
onPageChange(page: number) => voidNo
pageSizenumberNo
emptyMessageReact.ReactNodeNo
captionstringNo
onRowClick(row: T) => voidNo

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

PropTypeRequired
pressedbooleanNo

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

resthoverfocusactiveon

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.