Officina UI
Components

DataGrid

Spreadsheet-style data grid with sortable columns, double-click inline cell editing, and sticky headers.

DataGrid is the spreadsheet-style cousin of DataTable. It is also built on TanStack Table and takes data plus columns, but its focus is in-place editing: mark columns in editableColumns and users can double-click a cell to edit it, committing with Enter (and Escape to cancel) through onCellChange. It adds a sticky header (stickyHeader), sortable columns, and optional pagination. Choose DataGrid when users edit values directly in the table; choose DataTable for read-heavy lists with selection and export.

Example

Preview
Name
Status
OfficinaLive
TemplateDraft
import { DataGrid } from '@officina/ui';
import type { ColumnDef } from '@tanstack/react-table';

type Row = { sku: string; price: number };

const columns: ColumnDef<Row>[] = [
  { accessorKey: 'sku', header: 'SKU' },
  { accessorKey: 'price', header: 'Price' },
];

function PriceGrid({ rows }: { rows: Row[] }) {
  return (
    <DataGrid
      data={rows}
      columns={columns}
      editableColumns={['price']}
      stickyHeader
      onCellChange={(rowIndex, columnId, value) => console.log(rowIndex, columnId, value)}
    />
  );
}

API

PropTypeDefaultDescription
columns*DataGridColumn<TData>[]—Column definitions.
data*TData[]—Row data.
densityenum—Row height/padding density.
editableColumnsstring[]—Column accessorKey/id values that allow double-click inline editing.
filtersDataGridFilters<TData>—Per-column filter configuration.
globalFilterstring—Controlled global search term.
onCellChange(rowIndex: number, columnId: string, value: string) => void—Called when an editable cell is committed.
pageSizenumber—Rows per page; enables pagination when set.
stickyHeaderboolean—Keep the header visible while scrolling.

On this page