# Data table

import { Badge } from "@pycolors/ui";
import { Callout } from "fumadocs-ui/components/callout";
import { File, Files, Folder } from "fumadocs-ui/components/files";
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
import { Preview } from "@/components/docs/preview";
import {
  DataTableEmptyExample,
  DataTableExample,
  DataTablePageSizeExample,
  DataTableQueryExample,
  DataTableSortingExample,
} from "@/components/docs/blocks/data-table-example";

<div className="flex flex-wrap items-center gap-2">
  <Badge variant="outline">
    Data & records
  </Badge>

  <Badge>
    data-table
  </Badge>
</div>

## Browse records without adopting a data-grid framework

`DataTable` renders one typed record-browsing composition from consumer-owned
columns and rows. It provides deterministic ready, loading, empty and error
states, optional row actions, controlled query and sorting requests, page size,
and page navigation.

The Block never fetches, filters, sorts, mutates, routes or interprets records.
Those decisions remain in the consuming feature or data layer.

<Callout title="Source-copy Block">
  Copy the complete canonical directory into your application. There is no
  Blocks package, Registry installer, CLI, or automatic update channel for this
  Block today.
</Callout>

Pagination `previousLabel` and `nextLabel` customize both the visible controls and their accessible names. Use `morePagesLabel` for the ellipsis announcement. English labels remain the defaults.

## Canonical identity

| Contract                               | Value                                                     |
| -------------------------------------- | --------------------------------------------------------- |
| Category                               | `Data & records`                                          |
| Category slug                          | `data`                                                    |
| Block slug                             | `data-table`                                              |
| Source                                 | `apps/marketing/content/blocks/data/data-table/`          |
| Entry point                            | `apps/marketing/content/blocks/data/data-table/index.tsx` |
| Export                                 | `DataTable`                                               |
| Informational future Registry identity | `data-data-table`                                         |

The Registry identity is informational only. Registry installation is not
available, and this Block does not create a manifest, generated JSON, route or
delivery service.

## Copy source

Configure the [public UI package and tokens](/docs/ui/installation), then create
`src/components/blocks/data-table/` in your application. Copy all four files
below, keeping their relative imports and client directives. In the Source tab,
choose a file and use its copy button, or select the code manually when clipboard
access is unavailable.

To retrieve all four files at once, open **Code → Download ZIP** for Data table in
the [Blocks catalog](/blocks#category-data). Extract the archive and move its
`src/components/blocks/data-table/` folder into your application.

### File structure

<Files>
  <Folder name="src/components/blocks/data-table" defaultOpen>
    <File name="index.tsx" />

    <File name="pagination.tsx" />

    <File name="query-controls.tsx" />

    <File name="types.ts" />
  </Folder>
</Files>

| File                 | Responsibility                                                          |
| -------------------- | ----------------------------------------------------------------------- |
| `index.tsx`          | Table composition, sorting controls, display states and public exports. |
| `pagination.tsx`     | Page navigation, page-size selection and pagination validation.         |
| `query-controls.tsx` | Search input, filter slots, reset action and result summary.            |
| `types.ts`           | Typed columns, rows, controllers and component props.                   |

Import `DataTable` and its types from the directory's `index.tsx` entry point.
The separate controls keep customization local; data operations remain yours.

<Tabs groupId="blocks-doc-view" items={["Preview", "Source"]}>
  <Tab value="Preview">
    <Preview className="my-0 overflow-hidden">
      <DataTableExample />
    </Preview>
  </Tab>

  <Tab value="Source">
    <Tabs items={["index.tsx", "pagination.tsx", "query-controls.tsx", "types.ts"]}>
      <Tab value="index.tsx">
        ```tsx title="src/components/blocks/data-table/index.tsx"
        "use client";

        import {
          Alert,
          AlertDescription,
          AlertTitle,
          Table,
          TableBody,
          TableCaption,
          TableCell,
          TableEmpty,
          TableHead,
          TableHeader,
          TableLoading,
          TableRow,
          cn,
        } from "@pycolors/ui";

        import { DataTableQueryControls } from "./query-controls";
        import {
          DataTablePageSizeControls,
          DataTablePaginationControls,
          hasValidPagination,
        } from "./pagination";
        import type { DataTableProps } from "./types";

        export type {
          DataTableColumn,
          DataTableSort,
          DataTableSorting,
          DataTablePageSize,
          DataTablePagination,
          DataTableQuery,
          DataTableState,
          DataTableProps,
        } from "./types";

        /**
         * A source-copy record table with consumer-owned columns, rows, states,
         * actions, query and sorting requests, and controlled page navigation and size.
         */
        export function DataTable<Row>({
          caption,
          className,
          columns,
          emptyAction,
          emptyDescription,
          emptyTitle,
          getRowId,
          pagination,
          pageSize,
          query,
          renderRowActions,
          rowActionsLabel = "Actions",
          rows,
          sorting,
          state,
        }: DataTableProps<Row>) {
          const hasRowActions = Boolean(renderRowActions);
          const effectiveColumnCount = Math.max(
            1,
            columns.length + (hasRowActions ? 1 : 0),
          );
          const loadingLabel = state?.status === "loading" ? state.label : undefined;
          const status = state?.status ?? "ready";
          const showEmptyAction =
            status === "ready" && rows.length === 0 && Boolean(emptyAction);
          const showPagination =
            status === "ready" && rows.length > 0 && hasValidPagination(pagination);

          return (
            <div
              className={cn("min-w-0 space-y-4 rounded-[5px] bg-background", className)}
              data-slot="data-table"
            >
              {query ? <DataTableQueryControls query={query} /> : null}

              <Table className="min-w-max" data-slot="data-table-table">
                <TableCaption>{caption}</TableCaption>

                <TableHeader className="bg-muted/20 text-xs">
                  <TableRow>
                    {columns.map((column) => {
                      const controller = column.sortable ? sorting : undefined;
                      const direction =
                        controller?.value?.columnId === column.id
                          ? controller.value.direction
                          : undefined;
                      const nextDirection = direction === "asc" ? "desc" : "asc";

                      return (
                        <TableHead
                          aria-sort={
                            direction === "asc"
                              ? "ascending"
                              : direction === "desc"
                                ? "descending"
                                : undefined
                          }
                          className={column.headerClassName}
                          data-column-id={column.id}
                          key={column.id}
                        >
                          {controller ? (
                            <button
                              className="inline-flex min-h-11 sm:min-h-10 w-full cursor-pointer items-center gap-2 rounded-sm text-left font-medium outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
                              data-slot="data-table-sort-button"
                              disabled={status !== "ready"}
                              onClick={() =>
                                controller.onSortChange({
                                  columnId: column.id,
                                  direction: nextDirection,
                                })
                              }
                              type="button"
                            >
                              {column.header}
                              <span aria-hidden="true">
                                {direction === "asc"
                                  ? "▲"
                                  : direction === "desc"
                                    ? "▼"
                                    : "♢"}
                              </span>
                              <span className="sr-only">
                                :{" "}
                                {nextDirection === "asc"
                                  ? (controller.ascendingLabel ?? "Sort ascending")
                                  : (controller.descendingLabel ?? "Sort descending")}
                              </span>
                            </button>
                          ) : (
                            column.header
                          )}
                        </TableHead>
                      );
                    })}
                    {hasRowActions ? (
                      <TableHead
                        className="text-right"
                        data-slot="data-table-actions-header"
                      >
                        {rowActionsLabel}
                      </TableHead>
                    ) : null}
                  </TableRow>
                </TableHeader>

                <TableBody>
                  {status === "loading" ? (
                    <TableLoading
                      ariaLive={loadingLabel ? "off" : undefined}
                      colSpan={effectiveColumnCount}
                    />
                  ) : state?.status === "error" ? (
                    <TableRow className="hover:bg-transparent">
                      <TableCell className="p-4" colSpan={effectiveColumnCount}>
                        <Alert ariaLive="assertive" variant="destructive">
                          <AlertTitle>{state.title}</AlertTitle>
                          {state.description ? (
                            <AlertDescription>{state.description}</AlertDescription>
                          ) : null}
                          {state.action ? (
                            <div className="mt-3" data-slot="data-table-error-action">
                              {state.action}
                            </div>
                          ) : null}
                        </Alert>
                      </TableCell>
                    </TableRow>
                  ) : rows.length === 0 ? (
                    <TableEmpty
                      colSpan={effectiveColumnCount}
                      description={emptyDescription}
                      title={emptyTitle}
                    />
                  ) : (
                    rows.map((row) => {
                      const rowId = getRowId(row);

                      return (
                        <TableRow
                          data-row-id={String(rowId)}
                          data-slot="data-table-row"
                          key={rowId}
                        >
                          {columns.map((column) => (
                            <TableCell
                              className={column.cellClassName}
                              data-column-id={column.id}
                              key={column.id}
                            >
                              {column.cell(row)}
                            </TableCell>
                          ))}
                          {renderRowActions ? (
                            <TableCell
                              className="text-right"
                              data-slot="data-table-actions-cell"
                            >
                              {renderRowActions(row)}
                            </TableCell>
                          ) : null}
                        </TableRow>
                      );
                    })
                  )}
                </TableBody>
              </Table>

              {showEmptyAction ? (
                <div
                  className="flex min-w-0 flex-wrap justify-center gap-2"
                  data-slot="data-table-empty-action"
                >
                  {emptyAction}
                </div>
              ) : null}

              {loadingLabel ? (
                <span
                  aria-atomic="true"
                  aria-live="polite"
                  className="sr-only"
                  data-slot="data-table-loading-label"
                  role="status"
                >
                  {loadingLabel}
                </span>
              ) : null}

              {status === "ready" && rows.length > 0 && pageSize ? (
                <DataTablePageSizeControls pageSize={pageSize} />
              ) : null}

              {showPagination ? (
                <DataTablePaginationControls pagination={pagination} />
              ) : null}
            </div>
          );
        }

        ```
      </Tab>

      <Tab value="pagination.tsx">
        ```tsx title="src/components/blocks/data-table/pagination.tsx"
        "use client";

        import {
          Pagination,
          PaginationContent,
          PaginationEllipsis,
          PaginationItem,
          PaginationLink,
          buildPaginationRange,
          cn,
        } from "@pycolors/ui";
        import type { DataTablePageSize, DataTablePagination } from "./types";

        export function hasValidPagination(
          pagination: DataTablePagination | undefined,
        ): pagination is DataTablePagination {
          if (!pagination) return false;

          return (
            Number.isSafeInteger(pagination.page) &&
            Number.isSafeInteger(pagination.totalPages) &&
            pagination.totalPages > 1 &&
            pagination.page >= 1 &&
            pagination.page <= pagination.totalPages
          );
        }

        export function DataTablePageSizeControls({
          pageSize,
        }: Readonly<{ pageSize: DataTablePageSize }>) {
          const { label = "Rows per page", onPageSizeChange, value } = pageSize;
          const options = [
            ...new Set(
              pageSize.options.filter((size) => Number.isSafeInteger(size) && size > 0),
            ),
          ];

          if (options.length < 2 || !options.includes(value)) return null;

          return (
            <label
              className="flex min-w-0 flex-wrap items-center gap-2 text-sm"
              data-slot="data-table-page-size"
            >
              <span className="text-muted-foreground">{label}</span>
              <span className="relative inline-grid min-w-24 max-w-full">
                <select
                  className="h-11 w-full min-w-0 appearance-none truncate rounded-[5px] border border-input bg-background py-2 pl-3 pr-9 text-base leading-5 text-foreground shadow-xs outline-none transition-colors hover:border-border focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 sm:text-sm motion-reduce:transition-none"
                  data-slot="data-table-page-size-select"
                  onChange={(event) => {
                    const nextSize = Number(event.currentTarget.value);
                    if (nextSize !== value && options.includes(nextSize)) {
                      onPageSizeChange(nextSize);
                    }
                  }}
                  value={String(value)}
                >
                  {options.map((size) => (
                    <option key={size} value={String(size)}>
                      {size}
                    </option>
                  ))}
                </select>
                <svg
                  aria-hidden="true"
                  focusable="false"
                  viewBox="0 0 16 16"
                  fill="none"
                  className="pointer-events-none absolute right-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"
                >
                  <path
                    d="m4 6 4 4 4-4"
                    stroke="currentColor"
                    strokeWidth="1.5"
                    strokeLinecap="round"
                    strokeLinejoin="round"
                  />
                </svg>
              </span>
            </label>
          );
        }

        export function DataTablePaginationControls({
          pagination,
        }: Readonly<{ pagination: DataTablePagination }>) {
          const {
            navigationLabel = "Table pagination",
            nextLabel = "Next page",
            onPageChange,
            page,
            previousLabel = "Previous page",
            summary,
            totalPages,
          } = pagination;
          const tokens = buildPaginationRange({ page, totalPages });

          const requestPage = (nextPage: number) => {
            if (
              Number.isSafeInteger(nextPage) &&
              nextPage >= 1 &&
              nextPage <= totalPages &&
              nextPage !== page
            ) {
              onPageChange(nextPage);
            }
          };

          return (
            <div
              className={cn(
                "flex min-w-0 flex-col gap-3",
                "sm:flex-row sm:items-center sm:justify-between",
              )}
              data-slot="data-table-pagination"
            >
              {summary ? (
                <div
                  className="text-sm leading-6 text-muted-foreground"
                  data-slot="data-table-pagination-summary"
                >
                  {summary}
                </div>
              ) : (
                <span aria-hidden="true" />
              )}

              <Pagination
                aria-label={navigationLabel}
                className="w-auto justify-start sm:justify-end [&_button]:min-h-11 sm:[&_button]:min-h-10"
              >
                <PaginationContent className="!m-0 !max-w-none !p-0 [&>li]:!m-0 [&>li]:!p-0 [&>li]:before:hidden">
                  <PaginationItem>
                    <PaginationLink
                      aria-label={previousLabel}
                      className="gap-2 px-3"
                      data-slot="pagination-previous"
                      disabled={page === 1}
                      onClick={() => requestPage(page - 1)}
                      size="sm"
                    >
                      <svg
                        aria-hidden="true"
                        viewBox="0 0 24 24"
                        fill="none"
                        className="size-4"
                        stroke="currentColor"
                        strokeWidth="2"
                        strokeLinecap="round"
                        strokeLinejoin="round"
                      >
                        <path d="m15 18-6-6 6-6" />
                      </svg>
                      <span className="hidden sm:inline">
                        {pagination.previousLabel ?? "Previous"}
                      </span>
                    </PaginationLink>
                  </PaginationItem>

                  {tokens.map((token) =>
                    token.type === "ellipsis" ? (
                      <PaginationItem key={token.key}>
                        <PaginationEllipsis label={pagination.morePagesLabel} />
                      </PaginationItem>
                    ) : (
                      <PaginationItem key={token.value}>
                        <PaginationLink
                          aria-label={`Page ${token.value}`}
                          disabled={token.value === page}
                          isActive={token.value === page}
                          onClick={() => requestPage(token.value)}
                        >
                          {token.value}
                        </PaginationLink>
                      </PaginationItem>
                    ),
                  )}

                  <PaginationItem>
                    <PaginationLink
                      aria-label={nextLabel}
                      className="gap-2 px-3"
                      data-slot="pagination-next"
                      disabled={page === totalPages}
                      onClick={() => requestPage(page + 1)}
                      size="sm"
                    >
                      <span className="hidden sm:inline">
                        {pagination.nextLabel ?? "Next"}
                      </span>
                      <svg
                        aria-hidden="true"
                        viewBox="0 0 24 24"
                        fill="none"
                        className="size-4"
                        stroke="currentColor"
                        strokeWidth="2"
                        strokeLinecap="round"
                        strokeLinejoin="round"
                      >
                        <path d="m9 18 6-6-6-6" />
                      </svg>
                    </PaginationLink>
                  </PaginationItem>
                </PaginationContent>
              </Pagination>
            </div>
          );
        }

        ```
      </Tab>

      <Tab value="query-controls.tsx">
        ```tsx title="src/components/blocks/data-table/query-controls.tsx"
        "use client";

        import * as React from "react";
        import type { DataTableQuery } from "./types";

        export function DataTableQueryControls({
          query,
        }: Readonly<{ query: DataTableQuery }>) {
          const { filters, label = "Record filters", reset, search, summary } = query;
          const hasFilters = React.Children.toArray(filters).some(
            (node) => node !== "",
          );
          const hasSummary = React.Children.toArray(summary).some(
            (node) => node !== "",
          );

          return (
            <div
              aria-label={label}
              className="min-w-0 space-y-3"
              data-slot="data-table-query"
              role="group"
            >
              <div className="flex min-w-0 flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-end">
                <label
                  className="flex min-w-0 flex-1 flex-col gap-1 text-sm"
                  data-slot="data-table-search-label"
                >
                  <span className="text-muted-foreground">{search.label}</span>
                  <input
                    autoComplete="off"
                    className="min-h-11 sm:min-h-10 w-full min-w-0 rounded-md border border-border bg-background px-3 py-1 text-base text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 sm:text-sm"
                    data-slot="data-table-search"
                    disabled={search.disabled}
                    onChange={(event) => {
                      if (!search.disabled) {
                        search.onValueChange(event.currentTarget.value);
                      }
                    }}
                    onKeyDown={(event) => {
                      if (event.key === "Enter" && !event.nativeEvent.isComposing) {
                        event.preventDefault();
                      }
                    }}
                    placeholder={search.placeholder}
                    ref={search.inputRef}
                    type="search"
                    value={search.value}
                  />
                </label>
                {hasFilters ? (
                  <div
                    className="flex min-w-0 flex-wrap items-end gap-3"
                    data-slot="data-table-filters"
                  >
                    {filters}
                  </div>
                ) : null}
                {reset ? (
                  <button
                    className="inline-flex min-h-11 sm:min-h-10 shrink-0 cursor-pointer items-center justify-center rounded-md border border-border bg-background px-3 py-1 text-sm font-medium text-foreground outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
                    data-slot="data-table-query-reset"
                    disabled={reset.disabled}
                    onClick={reset.onReset}
                    type="button"
                  >
                    {reset.label}
                  </button>
                ) : null}
              </div>
              {hasSummary ? (
                <div
                  className="text-sm leading-6 text-muted-foreground"
                  data-slot="data-table-query-summary"
                >
                  {summary}
                </div>
              ) : null}
            </div>
          );
        }

        ```
      </Tab>

      <Tab value="types.ts">
        ```ts title="src/components/blocks/data-table/types.ts"
        import type * as React from "react";

        export type DataTableColumn<Row> = Readonly<{
          id: string;
          header: React.ReactNode;
          cell: (row: Row) => React.ReactNode;
          headerClassName?: string;
          cellClassName?: string;
          sortable?: boolean;
        }>;

        export type DataTableSort = Readonly<{
          columnId: string;
          direction: "asc" | "desc";
        }>;

        export type DataTableSorting = Readonly<{
          value: DataTableSort | null;
          onSortChange: (sort: DataTableSort) => void;
          ascendingLabel?: string;
          descendingLabel?: string;
        }>;

        export type DataTablePageSize = Readonly<{
          value: number;
          options: readonly number[];
          onPageSizeChange: (pageSize: number) => void;
          label?: string;
        }>;

        export type DataTablePagination = Readonly<{
          page: number;
          totalPages: number;
          onPageChange: (page: number) => void;
          navigationLabel?: string;
          previousLabel?: string;
          nextLabel?: string;
          morePagesLabel?: string;
          summary?: React.ReactNode;
        }>;

        export type DataTableQuery = Readonly<{
          label?: string;
          search: Readonly<{
            value: string;
            label: string;
            onValueChange: (value: string) => void;
            placeholder?: string;
            disabled?: boolean;
            inputRef?: React.Ref<HTMLInputElement>;
          }>;
          filters?: React.ReactNode;
          reset?: Readonly<{
            label: string;
            onReset: () => void;
            disabled?: boolean;
          }>;
          summary?: React.ReactNode;
        }>;

        export type DataTableState =
          | Readonly<{ status?: "ready" }>
          | Readonly<{ status: "loading"; label?: string }>
          | Readonly<{
              status: "error";
              title: string;
              description?: string;
              action?: React.ReactNode;
            }>;

        export type DataTableProps<Row> = Readonly<{
          caption: string;
          columns: readonly DataTableColumn<Row>[];
          rows: readonly Row[];
          getRowId: (row: Row) => React.Key;
          state?: DataTableState;
          emptyTitle: string;
          emptyDescription?: string;
          emptyAction?: React.ReactNode;
          renderRowActions?: (row: Row) => React.ReactNode;
          rowActionsLabel?: string;
          pagination?: DataTablePagination;
          pageSize?: DataTablePageSize;
          sorting?: DataTableSorting;
          query?: DataTableQuery;
          className?: string;
        }>;

        ```
      </Tab>
    </Tabs>
  </Tab>
</Tabs>

The Preview tab renders the real canonical `DataTable` through its deterministic
local fixture. It performs no data fetch or network request. The Source tab
includes the complete canonical files at build time, not a duplicated
implementation.

Your application copy does not receive automatic updates. Review later
canonical changes deliberately and validate it in your application before
adopting them. Return to the [Blocks catalog](/blocks) to choose another pattern.

## Install by copying source

1. Copy the complete `data-table` directory to an application-owned path, such
   as `src/components/blocks/data-table/`.
2. Install React 18 or newer and the public `@pycolors/ui` package.
3. Load `@pycolors/tokens/tokens.css` and configure the semantic Tailwind
   utilities used by the Block.
4. Import `DataTable` and its types from the copied local entry point.

```tsx title="records-table.tsx"
"use client";

import { DataTable, type DataTableColumn } from "./blocks/data-table";

type RecordRow = Readonly<{
  id: string;
  label: string;
  state: "Available" | "Paused";
}>;

const columns = [
  { id: "label", header: "Record", cell: (row) => row.label, sortable: true },
  { id: "state", header: "State", cell: (row) => row.state, sortable: true },
] satisfies readonly DataTableColumn<RecordRow>[];

export function RecordsTable({ rows }: { rows: readonly RecordRow[] }) {
  return (
    <DataTable
      caption="Available records"
      columns={columns}
      emptyDescription="Add a record to begin."
      emptyTitle="No records"
      getRowId={(row) => row.id}
      rows={rows}
    />
  );
}
```

## Consumer-owned contract

The consumer owns the row type, current rows, stable row IDs, unique column IDs,
headers, cell rendering, state copy, row actions, search values, filters,
matching rules, result counts, sort logic, pagination and page-size state.
`DataTable` does not infer identifiers from visible text or array positions and
does not interpret cell values.

The primary composition accepts `caption`, `columns`, `rows`, `getRowId`,
`emptyTitle`, optional `emptyDescription`, `emptyAction`, `renderRowActions`,
`rowActionsLabel`, `pagination`, `pageSize`, `sorting`, `query`, `state` and
`className`. Provide at least one meaningful column and keep row/column IDs
stable across rerenders.

## Search, filter, sort and paginate

Pass the optional `query` controller to compose a labelled live-search input,
consumer-owned filters, an optional reset action and result summary above the
table. The Block forwards raw controlled values; matching, debouncing, request
cancellation and page reset remain consumer responsibilities.

<Preview className="my-6 overflow-hidden">
  <DataTableQueryExample />
</Preview>

The demonstration searches a complete fictional collection before sorting and
pagination. Reset changes local demo state only. Nothing is requested or saved.
For remote records, use the server's matching total and ordering rather than
filtering only a downloaded page.

## Ready, loading, empty and error states

Ready is the default. Loading replaces stale rows with the public loading
presentation and suppresses pagination. Error presentation uses consumer-owned
copy and recovery actions while rows and pagination stay hidden. A ready empty
result is distinct from both loading and failure.

Pass `emptyAction` for a useful first-use or no-results next step. The action is
rendered unchanged outside the table scroller; record creation, filter reset,
permissions and focus after the empty state disappears remain consumer-owned.

<Preview className="my-6 overflow-hidden">
  <DataTableEmptyExample />
</Preview>

<Preview className="my-6 overflow-hidden">
  <DataTableEmptyExample filtered />
</Preview>

```tsx title="empty-table-action.tsx"
<DataTable
  {...tableProps}
  rows={filteredRows}
  emptyTitle="No matching records"
  emptyDescription="Clear your filters to see all available records."
  emptyAction={
    <button onClick={clearFilters} type="button">
      Clear filters
    </button>
  }
/>
```

## Optional row actions

`renderRowActions` receives the current row and may return consumer-owned
buttons, links or menus. Give every repeated control a specific accessible name.
The Block does not provide permissions, confirmation, routing, mutation or
destructive-action behavior and never makes the entire row interactive.

## Optional controlled pagination

Pagination is one-based. The Block renders valid page navigation from supplied
`page` and `totalPages`, emits only valid page requests, and does not slice rows,
fetch data, synchronize URLs or move focus. Those behaviors remain in the
consumer.

```tsx title="controlled-record-pages.tsx"
<DataTable
  {...tableProps}
  pagination={{
    navigationLabel: "Record pages",
    onPageChange: setPage,
    page,
    summary: `Page ${page} of ${totalPages}`,
    totalPages,
  }}
/>
```

## Optional controlled page size

Pass `pageSize` with a selected positive safe integer, allowed options and an
`onPageSizeChange` callback. The Block validates the presentation contract but
does not slice rows or reset the current page for you.

<Preview className="my-6 overflow-hidden">
  <DataTablePageSizeExample />
</Preview>

The example changes local size/page state and sorts a fresh copy before slicing.
Nothing is requested from a server or persisted. For server pagination, keep
approved sizes, true totals, cancellation and stale-result handling in your data
layer.

## Optional controlled sorting

Mark columns `sortable: true` and pass a `sorting` controller. Header buttons
request ascending or descending state; they do not reorder the supplied rows.
Your application must return rows that match the displayed sort state.

<Preview className="my-6 overflow-hidden">
  <DataTableSortingExample />
</Preview>

The active sortable header receives `aria-sort`; direction glyphs are decorative.
Tab, Enter and Space use native button behavior. Focus movement, comparator
choice, locale, page reset and remote ordering remain consumer-owned.

## Responsive and accessibility behavior

* Native table semantics remain intact at every viewport size.
* The table scrolls horizontally inside its bounded wrapper when needed.
* Query controls remain outside the table scroller and wrap on narrow layouts.
* Pagination and page-size controls use native, labelled controls.
* Loading, empty and error copy remain visible without relying only on color.
* Consumer row actions must remain keyboard operable and clearly labelled.
* The Block does not move focus after query, page, size or sort changes.

Focused semantic, interaction and representative axe tests verify these
contracts, but they are not a complete accessibility certification. Review real
long content, mobile widths, both themes, keyboard focus and assistive technology
in the consuming application.

## Deliberate exclusions

This Block does not include row selection, bulk actions, a filtering engine,
sorting engine, multi-column sorting, column visibility, resizing, reordering,
virtualization, inline editing, export, saved views, data fetching, server
pagination, caching, routing, permissions, mutations, authentication or billing.

It does not depend on TanStack Table, Next.js, Starter Free, Starter Pro,
private/deep package imports or a new runtime library. Compose product-specific
controls through `query.filters` or outside the Block and pass prepared rows.

## Ownership, updates and rollback

After copying, the consumer owns the source, integration, cell content, action
behavior, data lifecycle and future maintenance. There is no automatic update
or synchronization path. Compare future canonical revisions deliberately and
adopt only changes that fit the application.

Rollback is removal or reversion of the copied `data-table` directory and its
local integration. No package version, Registry state or remote Block state is
involved.