Skip to content
Niko Table

Basic Grid

The smallest Niko Grid: editable text cells, virtualization, and undo/redo.

This is the smallest useful Niko Grid. Start here when you want an editable table with the least code.

It uses useDataGrid, <DataGrid> and GridTextCell. You get:

  • Keyboard navigation
  • Undo and redo
  • A virtualized body (only visible rows render)

Clipboard, fill, toolbar and row menu are optional children. The demo mounts the common ones. Leave out what you do not need.

This page is also the model for new grid examples: see Documentation Guidelines.

grid-basic.tsx
Paste a spreadsheet (Ctrl/Cmd+V) to fill rows
TaskAssigneeStatus
Preview with Controlled State
grid-basic-state.tsx
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 Needs a fixed-height scroll container
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={…}>. Cells are found by row id, so focus and edits stay correct after you sort or filter.