Officina UI
Components

DataTable

Data-driven table built on TanStack Table with sorting, pagination, selection, and empty states.

DataTable is the high-level, data-driven table. Unlike the raw Table primitives (which you assemble row by row), you hand it data and TanStack Table columns and it renders the rows for you — with built-in sorting, optional pagination (pageSize), row selection (enableRowSelection), loading skeletons (isLoading), empty states, and a toolbar/export slot. Reach for it whenever the dataset is dynamic or large; use the Table primitives only for small, fully hand-controlled markup.

Example

Preview
OfficinaLive
TemplateDraft
Page 1 of 1
import { DataTable } from '@officina/ui';
import type { ColumnDef } from '@tanstack/react-table';

type User = { id: string; name: string; role: string };

const columns: ColumnDef<User>[] = [
  { accessorKey: 'name', header: 'Name' },
  { accessorKey: 'role', header: 'Role' },
];

function UsersTable({ users }: { users: User[] }) {
  return (
    <DataTable
      data={users}
      columns={columns}
      pageSize={10}
      enableRowSelection
      onRowSelectionChange={(rows) => console.log(rows)}
    />
  );
}

API

PropTypeDefaultDescription
columns*ColumnDef<TData, unknown>[]—TanStack Table column definitions.
data*TData[]—Row data.
densityenum—Row height/padding density.
emptyDescriptionstring—Description for the empty state.
emptyTitlestring—Heading for the empty state.
enableRowSelectionboolean—When set, table renders a checkbox column and reports row selection.
exportable{ columns?: ExportColumn<TData>[]; filename?: string; formats?: ExportFormat[]; scope?: "visible" | "all" | "selected"; }—
filtersDataTableFilters<TData>—
globalFilterstring—Controlled global search term.
isLoadingboolean—Show a loading skeleton instead of rows.
onRowClick(row: TData) => void—Called when a row is clicked.
onRowSelectionChange(rows: TData[]) => void—Called with the selected rows when selection changes.
pageSizenumber—Rows per page; enables pagination when set.
toolbarReactNode—Custom toolbar rendered above the table.

On this page