UI

Data grid

A virtualized spreadsheet grid with range selection, inline editing, fill handle, grouping with subtotals, .xlsx export, and selection-to-chart recommendations.

import { DataGrid } from '@uthereal/ui/data-grid'

Data grid playground

Oak lounge chair
Furniture
$64,000
$78,500
$91,200
42.5%
Jan 15, 2026
Arc floor lamp
Lighting
$52,000
$61,000
$74,800
48.0%
Feb 1, 2026
Handwoven wool rug
Textiles
$48,000
$53,400
$62,900
36.2%
Feb 18, 2026
Walnut writing desk
Furniture
$71,500
$84,200
$96,400
39.8%
Mar 4, 2026
Brass wall sconce
Lighting
$31,200
$38,900
$44,600
51.4%
Mar 22, 2026
Washed linen throw
Textiles
$24,800
$29,100
$33,500
46.1%
Apr 10, 2026
Glass pendant
Lighting
$39,400
$45,800
$54,200
44.7%
Apr 28, 2026
Cedar entryway bench
Furniture
$29,600
$35,200
$41,900
41.0%
May 12, 2026
8 rows
A1Count1

Product revenue
ProductCategoryQ1Q2Q3MarginLaunch
Oak lounge chairFurniture$64,000$78,500$91,20042.5%Jan 15, 2026
Arc floor lampLighting$52,000$61,000$74,80048.0%Feb 1, 2026
Handwoven wool rugTextiles$48,000$53,400$62,90036.2%Feb 18, 2026
Walnut writing deskFurniture$71,500$84,200$96,40039.8%Mar 4, 2026
Brass wall sconceLighting$31,200$38,900$44,60051.4%Mar 22, 2026
Washed linen throwTextiles$24,800$29,100$33,50046.1%Apr 10, 2026
Glass pendantLighting$39,400$45,800$54,20044.7%Apr 28, 2026
Cedar entryway benchFurniture$29,600$35,200$41,90041.0%May 12, 2026
Loading interactive preview…

Overview

A data grid displays and edits structured tabular datasets in place like a spreadsheet. Readers select rectangular cell ranges, edit text, numbers, select options, or dates inline, drag the fill handle to extend numeric or date series, copy and paste with Excel or Google Sheets, sort across multiple columns, filter by column syntax, group rows with subtotals, and export CSV or .xlsx workbooks.

When two or more cells are selected, the status bar runs the deterministic recommendCharts() engine on the selection and surfaces a ranked chart switcher. Hosts can render live chart previews inside the popover via renderChartPreview and handle chart insertion through onVisualize or visualizeAction.

Use DataGrid when readers edit many cells in place, analyze multi-column financial or operational data, or jump directly from tabular selections to charts. For read-only record lists without spreadsheet editing, use a simpler table layout. For single-record editing, use form inputs.

Usage

import { useState } from 'react'
import {
  DataGrid,
  type DataGridColumnInput,
  type DataGridRow,
} from '@uthereal/ui/data-grid'

const columns: DataGridColumnInput[] = [
  { id: 'item', label: 'Item', width: 180, pinned: true },
  {
    id: 'status',
    label: 'Status',
    type: 'select',
    options: ['Planned', 'Active', 'Done'],
  },
  { id: 'q1', label: 'Q1', type: 'currency' },
  { id: 'q2', label: 'Q2', type: 'currency' },
  {
    id: 'margin',
    label: 'Margin',
    type: 'percent',
    decimals: 1,
    editable: false,
  },
  { id: 'target', label: 'Target', type: 'date' },
]

export function BudgetGrid() {
  const [rows, setRows] = useState<DataGridRow[]>([
    {
      id: 'r1',
      item: 'Design systems',
      status: 'Active',
      q1: 42000,
      q2: 48500,
      margin: 34.5,
      target: '2026-03-31',
    },
    {
      id: 'r2',
      item: 'Cloud hosting',
      status: 'Planned',
      q1: 18400,
      q2: 21000,
      margin: 22.0,
      target: '2026-06-30',
    },
  ])

  return (
    <DataGrid
      label="Operating budget"
      columns={columns}
      rows={rows}
      onRowsChange={setRows}
      exportFormats={['csv', 'xlsx']}
    />
  )
}

Every column needs a unique id matching the keys on each row, and every row needs a stable unique id. Store raw numbers for number, currency, and percent columns (34.5 renders as 34.5%) and ISO calendar days (YYYY-MM-DD) for date columns.

Examples

Grouping and subtotals

Pass column ids in groupBy to nest rows into an expandable treegrid. Each group header shows its item count and computes subtotals using each column's aggregate. Exporting .xlsx writes outlined group rows with native Excel SUBTOTAL formulas so grand totals never double-count subtotals.

$62,800
$68,600
81.3%
Cloud compute
Engineering
$48,200
$52,400
78.4%
CI runners
Engineering
$14,600
$16,200
84.1%
$22,200
$25,200
88.9%
Design tooling
Design
$9,400
$9,800
91.2%
User research
Design
$12,800
$15,400
86.5%
$39,500
$38,400
81.2%
Compliance audit
Operations
$22,000
$19,500
74.0%
Support desk
Operations
$17,500
$18,900
88.3%
6 rows
A1Count1

Quarterly spend by department
Line itemDepartmentQ1Q2Efficiency
Cloud computeEngineering$48,200$52,40078.4%
CI runnersEngineering$14,600$16,20084.1%
Design toolingDesign$9,400$9,80091.2%
User researchDesign$12,800$15,40086.5%
Compliance auditOperations$22,000$19,50074.0%
Support deskOperations$17,500$18,90088.3%

Inline editing and bulk actions

Combine select, date, currency, and read-only (editable: false) columns with bulkActions and exportFormats: ['csv', 'xlsx']. Double-click a cell or press Enter to edit, drag the corner fill handle to continue numeric or date runs, and check rows in the gutter to reveal bulk actions.

Schema v2
Done
$24,000
100%
Jan 31, 2026
Core
Streaming API
Active
$38,500
72%
Feb 28, 2026
Platform
Audit exports
Active
$19,200
45%
Mar 31, 2026
Security
Regional failover
Planned
$44,000
10%
Apr 30, 2026
Infra
4 rows
A1Count1

Release milestones
MilestoneStatusBudgetCompleteTarget dateOwner
Schema v2Done$24,000100%Jan 31, 2026Core
Streaming APIActive$38,50072%Feb 28, 2026Platform
Audit exportsActive$19,20045%Mar 31, 2026Security
Regional failoverPlanned$44,00010%Apr 30, 2026Infra

Behavior

Column types

TypeAlignmentParsing & editingDefault aggregate
textStartPlain text input; accent-insensitive substring, =exact, !excludenone
numberEndParses commas, spaces, minus, accounting (12); range 10..50sum
currencyEndFormats with $ or column.currency ISO code; parses $ on pastesum
percentEndStores human percentages (32.5 → 32.5%); parses % on pasteaverage
selectStartCombobox listbox matching options case-insensitively; checklist filternone
dateStartISO day (YYYY-MM-DD) in UTC; DateInput calendar popover; 2026-01..2026-03none

Selection-to-chart engine (recommendCharts)

Selecting two or more cells runs recommendCharts() on the deferred range (never mid-drag) and ranks up to six compatible @uthereal/ui chart types across all 20 shipped chart components.

ExportPurpose
recommendChartsProfiles selected columns and returns ranked ChartRecommendation[] with lazy buildProps()
inferColumnProfileInfers numeric, temporal, categorical, percentage, currency, and geographic column metadata
renderChartPreviewReact slot receiving the active ChartRecommendation to mount a live chart inside the popover
onVisualizeFires with (recommendation, range) when the reader confirms "Insert chart"
visualizeActionNamed host action dispatched through onAction(action, 'data-grid') on confirmation

Virtualization, clipboard, and remote blocks

Both rows (overscan 6) and scrolling columns (overscan 240 px) are virtualized while pinned columns, the active cell, and the active editor stay mounted. Sorting reorders the view once so editing values never causes rows to jump under the cursor. Undo and redo retain up to 100 row snapshots.

For server-sized datasets, supply getRows (and optional blockSize, default 100): the grid loads blocks covering the viewport on scroll, caches up to 40 blocks, and resets the cache whenever sort, filters, or search change.

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
labelstringDefault: "Data"Accessible name for the grid. It also names the exported CSV file.
columnsDataGridColumn[]Default: [{"id":"name","label":"Name","type":"text","pinned":true},{"id":"amount","label":"Amount","type":"currency"},{"id":"date","label":"Date","type":"date"}]Column definitions in definition order, each with a unique id; pinned columns are drawn first. Up to 100.
rowsDataGridRow[]Default: []Starting rows when uncontrolled, each with a unique id. Up to 10,000.
maxHeightintegerDefault: 400Tallest the scrolling area grows before it scrolls, in px (160–4000).
sortDataGridSort[]Default: []Starting sort keys in priority order. Header clicks and the header menu report changes through onSortChange.
filtersDataGridFiltersDefault: {}Starting column filters keyed by column id. Text and number columns take a query string; select columns take the values to keep.
selectedRowIdsstring[]Default: []Starting checked row ids in data order.
hiddenColumnsstring[]Default: []Starting hidden column ids; defaults to the columns that set hidden.
pinnedColumnsstring[]Default: []Starting pinned column ids; defaults to the columns that set pinned, or the first column.
densityDataGridDensityDefault: "standard"Row height: compact 32, standard 40, comfortable 48 px.
groupBystring[]Default: []Group-by column ids, outermost first. Each group row shows a toggle, its value and row count, and a subtotal.
rowSelectionbooleanDefault: trueShows the row gutter with row numbers and checkboxes.
rowNumbersbooleanDefault: trueShows the row number in the gutter.
selectionStatsbooleanDefault: trueShows the active cell address and the Count, Sum and Average of the selected cells in the status bar.
toolbarbooleanDefault: trueShows the toolbar with search, undo and redo, filters, columns, density and export.
totalsbooleanDefault: trueShows the sticky totals row; it covers every row the filters keep.
visualizebooleanDefault: trueShows the selection-to-chart action in the status bar when selected cells can be charted.
visualizeActionstring—Host-registered action sent when the reader confirms a chart recommendation, e.g. insert_chart.
exportFormats("csv" | "xlsx")[]Default: ["csv"]Formats Export offers. With more than one, Export opens a menu. xlsx keeps number formats, column widths, a frozen header, bold totals and groups as outlined rows with SUBTOTAL formulas.
exportFileNamestring—Export file name without the extension. Defaults to a slug of label.
canDeleteRowsbooleanDefault: trueShows Delete for checked rows. Deleting can be undone.
bulkActionsDataGridBulkAction[]Default: []Extra toolbar actions for checked rows, shown between Export and Delete, each with a unique id.
loadingbooleanDefault: falseShows placeholder rows and sets aria-busy.
emptyLabelstringDefault: "No rows yet"Shown when there are no rows at all.
searchLabelstringDefault: "Search"Accessible name of the quick search field.
localestring—BCP 47 locale for formats. Omit it to inherit the page locale.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeDataGridTheme—Color mode, accent, and tokens. See Theming.
motionnone | subtle | expressiveDefault: "subtle"Group and status-bar animation preset. System reduced-motion preferences take precedence.
motionOptionsDataGridMotionOptions—Group open/close and status-bar transitions: a tween (ms) or a spring.
dirltr | rtl—Reading direction. Omit it to inherit the page direction.

React integration

PropPurpose
onRowsChangeFires with the full row array after edits, fills, pastes, cuts, clears, deletes, undo, redo
onSortChange, onFiltersChangeControlled callbacks for multi-column sort and column filter maps
onSelectedRowIdsChange, onHiddenColumnsChange, onPinnedColumnsChange, onDensityChange, onGroupByChangeControlled callbacks for grid view state
defaultRows, defaultSort, defaultFilters, defaultSelectedRowIds, defaultHiddenColumns, defaultPinnedColumns, defaultDensity, defaultGroupByUncontrolled initial values
getRows, blockSizeHost-owned remote block loader (request) => Promise<DataGridRowsResult>
renderChartPreviewRenders a live chart preview for the active ChartRecommendation inside the status popover
onVisualizeFires with (recommendation, range) when the reader confirms a recommended chart
onActionHost action handler (action, itemId?) for visualizeAction and bulkActions
preset, tokensApplication defaults and --ui-* CSS variable overrides
ref, className, styleForwarded to the root grid container

Keyboard & accessibility

KeyInteraction
Arrow keysMove active cell (inline axis mirrors automatically in dir="rtl")
Shift + ArrowExtend rectangular selection range from anchor
Cmd/Ctrl + ArrowJump to grid edge (+ Shift extends range)
Home, EndMove to first or last column (Cmd/Ctrl jumps to first or last grid cell)
PageUp, PageDownMove by one visible page of rows
Cmd/Ctrl + ASelect all cells
Ctrl + Space / Shift + SpaceExtend selection to full columns / toggle row checks across selected rows
Enter, F2 / any characterEdit active cell keeping value / start editing replacing value
Enter, Tab (editing)Commit edit and move down/up (Shift+Enter) or end/start (Shift+Tab)
EscapeCancel edit, collapse selection range to active cell, or clear checked rows
Delete, BackspaceClear editable cells in range (read-only cells skipped)
Cmd/Ctrl + DFill down from top row of selection
Cmd/Ctrl + C, X, VCopy, cut, or paste TSV and HTML tables (tiles whole multiples)
Cmd/Ctrl + Z, Shift+Z / YUndo or redo up to 100 steps
Alt + ArrowLeft / ArrowRightNarrow or widen focused header column by 16 px

The grid renders role="grid" (or role="treegrid" when groupBy is active) with aria-multiselectable, aria-rowcount, aria-colcount, aria-rowindex, aria-colindex, aria-sort, and aria-busy. Group rows expose aria-level and aria-expanded; totals and subtotals carry full spoken labels. A polite role="status" region announces edits, sorts, copies, pastes, fills, deletes, and undo/redo, while a visually hidden native <table> provides a static screen-reader overview. Under forced-colors: active, selection fills and active borders map to system Highlight colors.

Motion and theming

Toolbar swaps, the filter row glide, and status bar notifications animate through LazyMotion and resolveDataGridMotion. motionOptions.groupDuration and motionOptions.statusDuration accept durations in milliseconds, and motionOptions.selection accepts a tween or spring. Under prefers-reduced-motion: reduce, travel, press scale, error shake, and skeleton pulse disable in favor of 120 ms opacity fades; motion="none" makes every transition immediate (0 ms).

TokenCSS variableDefaultPurpose
rowHeight--ui-data-grid-row-height40pxStandard row height
rowHeightCompact--ui-data-grid-row-height-compact32pxCompact density row height
rowHeightComfortable--ui-data-grid-row-height-comfortable48pxComfortable density row height
headerHeight--ui-data-grid-header-height40pxSticky column header height
gutter--ui-data-grid-gutter48pxRow number and checkbox gutter
cellPad--ui-data-grid-cell-pad12pxCell inline padding
cellText / cellTextMono--ui-data-grid-cell-text / -mono13px / 12pxBody and numeric cell type scale
frameRadius--ui-data-grid-frame-radius16pxOuter grid frame corner radius
focusWidth--ui-data-grid-focus-width2pxActive cell inset border width

theme also accepts global mode, accent, surface, border, control, and popup tokens. An application-wide UtherealProvider supplies defaults.

Composition

In an agent composition, DataGrid is a leaf component. Declare visualizeAction and bulkActions[].action with registered snake_case host actions; the grid reports them via onAction(action, itemId). See Building with agents.

{
  "type": "DataGrid",
  "props": {
    "label": "Q4 pipeline",
    "visualizeAction": "insert_chart",
    "columns": [
      { "id": "account", "label": "Account", "type": "text", "pinned": true },
      {
        "id": "stage",
        "label": "Stage",
        "type": "select",
        "options": ["Qualified", "Proposal", "Closed"]
      },
      { "id": "value", "label": "Value", "type": "currency" }
    ],
    "rows": [
      {
        "id": "r1",
        "account": "Northwind",
        "stage": "Proposal",
        "value": 84000
      },
      { "id": "r2", "account": "Fabrikam", "stage": "Closed", "value": 62000 }
    ]
  },
  "children": []
}

On this page