Skip to content
Eskais UI

Server data

Server Data Table

A DataTable over a PageSource: the server filters, sorts and pages; page numbers, previous and next, or load more follow what the source gives; DataState covers loading, error with retry and empty; a polite status says "Showing 21–40 of 312" after each load; filters, sort and page can live in the URL.

Example

Status

Installation

npx shadcn@latest add @eskais/server-data-table

Usage

Import
import { ServerDataTable } from "@/components/ui/server-data-table"import { ServerTableNavigation, ServerTablePageSize, serverDataTableLabels } from "@/components/ui/server-data-table-parts"

Wrap your endpoint in a PageSource, declare the filters once, and the table pages, sorts, filters and keeps it in the URL.

API reference

ServerDataTable

PropTypeDefault
labelrequiredNames the table, for screen readers and agents.string–
sourcerequiredPageSource<T, FilterValues<S>>–
columnsrequiredGive a column `sortField` to sort it on the server.readonly DataTableColumn<T>[]–
filtersS–
filterUiThe built-in filter UI: `"search"` (default when the schema has a text field), `"chips"` (search and `FilterChips`) or `"panel"` (search and a `FilterPanel` beside the table, a sheet on narrow screens). Ignored with `toolbar`."search" | "chips" | "panel" | "none"–
toolbarFilter UIs of your own, composed from the parts; they find the schema and controller from the table.ReactNode–
defaultFiltersFilterValues<S>–
defaultSortreadonly SortSpec[]noSort
sortMode`"multi"`: Shift+click adds a column to the sort. Default `"single"`."single" | "multi""single"
pageSizenumber25
pageSizesreadonly number[]defaultPageSizes
navigationDefault `"auto"`: page numbers with an exact total, previous and next without, load more for a cursor.NavigationMode"auto"
urlStateKeeps filters, sort and page in the URL: `hashUrlState()`, `historyUrlState()` or your router's adapter.UrlStateAdapter | ServerTableUrlState–
refetchIntervalReloads the shown rows every so many ms while the document is visible, as the hooks' `refetchInterval`: the rows stay, unmarked, and the status announces nothing. Default false.number | falsefalse
refetchIntervalInBackgroundKeeps polling while the document is hidden, as the hooks' `refetchIntervalInBackground`. Default false.booleanfalse
controllerA controller of your own, from `usePageController`, to drive the table from outside.PageController<FilterValues<S>>–
labelsrequiredServerDataTableLabels–
localeFormats the counts, dates and numbers it shows; the page's `<html lang>` by default (`useLocale`).string–
classNamestring–

Also takes Pick< DataTableProps<T>, | "getRowLabel" | "selectable" | "selection" | "defaultSelection" | "onSelectionChange" | "onRowOpen" | "virtualize" | "estimateSize" | "loadingRows" | "tableClassName" >.

ServerTableNavigation

PropTypeDefault
labelrequiredThe table's label, for the navigation's name.string–
navigationrequiredNavigation–
pagerequirednumber–
pageCountrequirednumber–
onPageChangerequired(page: number) => void–
hasMorerequiredboolean–
loadingMorerequiredboolean–
onLoadMorerequired() => unknown–
labelsrequiredResolvedLabels–

ServerTablePageSize

PropTypeDefault
sizerequirednumber–
sizesrequiredreadonly number[]–
onSizeChangerequired(size: number) => void–
labelrequiredstring–
localestring–

Other exports

serverDataTableLabelstype ServerDataTableFilterUitype ServerDataTableLabelstype ServerDataTablePropstype ServerTableUrlStatetype ResolvedLabelstype ServerTableNavigationPropstype ServerTablePageSizeProps

Accessibility

  • A polite status says what is shown after each load ("Showing 21–40 of 312"), and "Loading…" only once a load has taken 400 ms.
  • Focus stays on the control you pressed; new rows never take it. Row navigation starts again at the first row without moving focus.
  • While a page loads the table keeps its rows and is marked aria-busy; it never says empty while loading or after an error.

Agent actions

Agents sort and page through the table's own actions (sortBy, setPage) and filter through the filters group: filter("Status", ["Open"]), clearFilters(). Every control is a named UI SDK part.

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