Skip to content
Eskais UI

Data

Data Table

Generic typed table: sortable columns with aria-sort, optional row selection with a mixed select-all, loading and empty states, and pagination through renderPagination. Sort, selection and page are controlled or not, and agents can sort, select and page it.

Example

Apolloeu-west12
Borealisus-east31
Cygnusap-south—
Dracoeu-west7
Eridanusus-east44
Page 1 of 2

Installation

npx shadcn@latest add @eskais/data-table
npm packagesclass-variance-authority@0.7.1lucide-react

Usage

Import
import {  clampPage,  compareSortValues,  nextSort,  pageCountOf,  paginate,  selectionState,  sortRows,  toggleIds,} from "@/lib/data-table-model"import { createDataTableController, dataTable } from "@/components/ui/data-table-primitive"import {  DataTableCheckbox,  DataTableHeaderCell,  dataTableLabels,  DataTablePagination,} from "@/components/ui/data-table-parts"import { DataTableEmptyRow, DataTableGapRow, DataTableLoadingRows, DataTableRow } from "@/components/ui/data-table-row"import { createDataTableController, DataTable, dataTableLabels } from "@/components/ui/data-table"import { cellNavigation } from "@/components/ui/cell-navigation-primitive"import {  CellNavigationProvider,  NavigableCell,  useCellNavigation,  useCellNavigationActive,} from "@/components/ui/cell-navigation"

API reference

DataTableHeaderCell

PropTypeDefault
columnrequiredDataTableColumn<Row>–
sortrequiredDataTableSort | null–
sortablerequiredboolean–
secondaryDataTableSecondarySort–
labelsrequiredPick<DataTableLabels, "sortBy" | "sortRank">–
onSortrequired(event: MouseEvent) => void–

DataTableCheckbox

PropTypeDefault
labelrequiredstring–
checkedrequiredCheckedState–
disabledboolean–
onChangerequired(checked: boolean, event?: Event) => void–
tabIndexnumber–

DataTablePagination

PropTypeDefault
pagerequirednumber–
pageCountrequirednumber–
pageSizerequirednumber–
totalrequirednumber–
onPageChangerequired(page: number, options?: DataTablePageOptions) => void–
labelsrequiredPick<DataTableLabels, "previousPage" | "nextPage" | "pageStatus">–

DataTableGapRow

PropTypeDefault
columnsrequirednumber–
sizerequirednumber–
childrenReactNode–

DataTableEmptyRow

PropTypeDefault
columnsrequirednumber–
childrenReactNode–

DataTableLoadingRows

PropTypeDefault
rowsrequirednumber–
columnsrequirednumber–

DataTable

Takes DataTableProps.

CellNavigationProvider

PropTypeDefault
handlerequiredCellNavigationHandle | null–
childrenrequiredReactNode–

NavigableCell

PropTypeDefault
rowrequirednumber–
colrequirednumber–
renderrequiredReactElement–

Other exports

clampPagecompareSortValuesnextSortpageCountOfpaginateselectionStatesortRowstoggleIdscreateDataTableControllerdataTabledataTableLabelsDataTableRowcellNavigationuseCellNavigationuseCellNavigationActivetype DataTablePagetype DataTableSorttype SelectionStatetype SortDirectiontype SortValuetype DataTableControllertype DataTableItemtype DataTableOptionstype DataTablePageChangeReasontype DataTableSelectionChangeReasontype DataTableSortChangeReasontype DataTableSecondarySorttype DataTableAligntype DataTableColumntype DataTableLabelstype DataTablePageOptionstype DataTablePaginationPropstype DataTablePropstype DataTableRowPropstype CellNavigationOptionstype CellNavigationHandle

Accessibility

  • Sortable columns with aria-sort, row selection by label, pagination and a loading state.

Agent actions

Agents sort, select rows by label and page through it.

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.