Skip to content

Basic Grid

Minimal editable Data Grid with text cells, virtualization, and undo/redo.

The smallest useful Data Grid: useDataGrid + <DataGrid> + GridTextCell. You get keyboard navigation, undo/redo, and a virtualized body. Clipboard, fill, toolbar, and the row menu are opt-in children — the demo below mounts the common ones; leave out what you don’t need.

This page is the reference shape for new grid examples: see Documentation Guidelines.

Open in
Paste a spreadsheet (Ctrl/Cmd+V) to fill rows
TaskAssigneeStatus
Preview with Controlled State
Open in
Paste a spreadsheet (Ctrl/Cmd+V) to fill rows
TaskAssigneeStatus
Current Grid State
Live view of the grid engine state for demonstration
Focused Cell:None
Editing Cell:None
Selection Anchor:None
Total Rows:3
Can Undo / Redo:No / No
Last Commit:None
pnpm dlx shadcn@latest add @niko-table/data-table-grid

First time using @niko-table? See the Installation Guide.

Piece Role
useDataGrid Headless rows, focus, edit lifecycle, undo/redo
<DataGrid> Keyboard nav + selection around DataTable
<DataGridCell> Id-addressed cell wrapper (not TanStack row.index)
GridTextCell Text editor (display shell; editor mounts on edit)
Virtualized body Fixed-height scroll container required
Opt-in children Demo mounts clipboard, fill handle, toolbar, row menu
const grid = useDataGrid({
columnIds: ["task", "assignee", "status"],
createEmptyRow,
initialRows,
})
<DataTableRoot data={grid.rows} columns={columns} getRowId={(r) => r.id}>
<DataGrid grid={grid}>
<DataTable maxHeight={360}>
<DataTableVirtualizedHeader />
<DataTableVirtualizedBody estimateSize={37} />
</DataTable>
</DataGrid>
</DataTableRoot>

Column cell renderers wrap editors in <DataGridCell row={…} columnId={…}>. Focus and edits stay correct after sort/filter because addressing is by row id.