Skip to content
Skip to Content
ComposerKit
Guides

Data grid

Configure virtualization, filtering, grouping, editing, server row models, range charts, and export in @composerkit/data-grid.

@composerkit/data-grid exports TableCore and createAlignedGridGroup for dense tabular workspaces. It reuses ComposerKit's Button, Checkbox, Input, and Base UI primitives under one shared CSS token sheet.

Install it into your app with:

npx shadcn add @composerkit/data-grid --overwrite --yes

Capabilities at a glance

SubsystemKey props, columns, and handle methodsNotes
Virtualization and pinningpinnedRows ({ top, bottom }), pinnedColumns, domLayout, autoHeight, wrapTextWindows rows (100k+) and columns (200+) automatically inside .tablecore-viewport.
Filtering and sortingColumnDef: sortable, filterable, filterType, multiFilterTypes; props: enableAdvancedFilterSupports text, number, date, set, multi, and expression-based advanced filters.
Hierarchy and pivotColumnDef: groupable, pivot, aggFunc, showValuesAs; props: treeData, pivotMode, aggFuncs, stickyGroupRowsTree mode reads nested RowData.children and preserves selection and expansion by row identity.
Editing and clipboardColumnDef: editable, editor, editorComponent, validate; props: fullRowEdit, undoRedoCellEditing, undoRedoLimit, cellSelection, enableFormulas, enableNotesIncludes rich-select, batch editing (startBatchEdit, commitBatchEdit, cancelBatchEdit), fill handle (cellSelection.handle), and clipboard copy/cut/paste.
Remote row modelsrowModelType ("serverSide", "infinite", "viewport") with serverSideDatasource or datasourceSupports block caching, server sort/filter/grouping, transactions, and pushed rows.
Charts and exportColumnDef: sparkline; TableCoreHandle: createRangeChart, getChartImageDataURL, exportDataAsCsv, exportDataAsExcel, exportDataAsPdfUses isolated chart.js canvases for inline charts and shared @composerkit/excel for .xlsx.
AI state integrationTableCoreHandle: getStructuredSchema(), getGridAiState(), setGridAiState()Exposes structured filter, sort, group, and column state for model tool calls.

Virtualization and keyboard contracts

TableCore virtualizes both rows and center columns automatically inside .tablecore-viewport, keeping pinned regions and any currently focused or actively edited cell mounted.

  • Set the viewport height with --tablecore-height (defaults to 65vh) and default column width with --tablecore-column-width.
  • Pin rows with pinnedRows={{ top, bottom }} (or setRowPinned on TableCoreHandle) and pin left columns with pinnedColumns.
  • Focus uses a single roving tabIndex={0} stop inside the grid body. Arrow keys, Home, End, Ctrl+Home, Ctrl+End, PageUp, and PageDown navigate across virtualized and pinned boundaries.
  • Active editors keep their draft and remain mounted during both-axis scrolling. Tab and Shift+Tab commit and advance across unmounted row and column windows.
  • aria-rowcount and aria-colcount report logical dimensions including header and pinned regions.

Filtering, grouping, and pagination

  1. Typed column filters: set filterable: true and filterType ("text", "number", "date", "set", "multi") on ColumnDef, plus multiFilterTypes when combining filters on one column. Text filters debounce automatically while number and date drafts wait for Apply.
  2. Advanced filter bar: enable enableAdvancedFilter for an interactive expression bar (Amount > 15 AND Region = "North"), controlled programmatically via setAdvancedFilterModel() and getAdvancedFilterModel().
  3. Grouping and tree data: mark flat columns groupable: true or pass treeData with nested RowData.children. Synthetic group rows carry aggFunc rollups (sum, avg, min, max, count, first, last, or custom aggFuncs), groupTotalRow/grandTotalRow, and showValuesAs percentages.
  4. Pagination: set pageSize on client-side or server-side grids to bound logical rows before virtualization. In grouped or tree grids, pagination counts root groups or root parents while keeping expanded descendants on their root page.

Server-side, infinite, and viewport row models

Select a remote row model with rowModelType instead of passing rows:

rowModelTypeRequired datasource propsBehavior
"serverSide"serverSideDatasource, pageSize, cacheBlockSizeRequests typed blocks (ServerSideRequest), caches blocks, and supports refreshServerSide() and applyServerSideTransaction().
"infinite"datasource (InfiniteDatasource), cacheBlockSizeLoads fixed-size row blocks on demand as the viewport scrolls; inspect or clear with getInfiniteState() and purgeInfiniteCache().
"viewport"datasource (ViewportDatasource)Subscribes to the visible row range and accepts server-pushed row updates via setRowCount and setRowData.

Inline charts, sparklines, and export

  • Chart boundary: TableCore keeps chart.js isolated inside components/data-grid/chart-renderer.ts and components/data-grid/sparkline.tsx. Canvas rendering preserves synchronous getChartImageDataURL() snapshots for Excel PNG embedding and high-density cell sparklines. For standalone dashboard charts outside the grid, use @composerkit/charts.
  • Range charts: create and manage charts from TableCoreHandle with createRangeChart(), getChartModels(), updateChart(), restoreChart(), and downloadChartImage().
  • Excel export: getDataAsExcel(), exportDataAsExcel(), getMultipleSheetsAsExcel(), and exportMultipleSheetsAsExcel() use ComposerKit's unified @composerkit/excel helper (write-excel-file/universal) with styled cells, formulas, multi-sheet workbooks, and embedded images.
  • CSV and PDF export: getDataAsCsv() / exportDataAsCsv() write CSV, and getDataAsPdf() / exportDataAsPdf() write standalone binary PDF documents without requiring a browser print dialog.

Styling tokens

Override these CSS custom properties on any container wrapping TableCore:

TokenPurpose
--tablecore-heightScroll viewport max-height (default 65vh).
--tablecore-column-widthDefault virtualized column width.
--tablecore-pinned-backgroundOverride pinned row and column background (defaults to --grid-pinned).
--grid-selectedSelected row background fill.
--grid-rangeCell range selection outline and highlight accent.

Continue to the Data grid component reference for live demos and generated TypeScript props.

On this page