caliper uidocs

Data grid

Pro

A spreadsheet-style grid with editable cells and formulas.

Installs components/ui/data-grid.tsxDepends on none beyond ReactMotion none in component source
pnpm dlx shadcn@latest add @caliper/data-grid

Change a month and the totals follow. Select a block to see its sum below. Try typing =MAX(B2:D2) in a cell.

A1
RowABCDEFG
1Budget lineJanuaryFebruaryMarchQuarterShare %
2Salaries84,00084,00086,500254,50063.28
3Cloud hosting12,40013,15014,90040,450
4Software licences6,2006,2006,90019,300
5Marketing9,50015,20011,80036,500
6Travel2,1003,4005,20010,700
7Office4,3004,3004,30012,900
8Contractors7,8009,1006,40023,300
9Training8001,5002,2004,500
10
11Total127,100136,850138,200402,150
12Monthly average15,887.517,106.2517,275134,050
13
14

When to use #

Use it for

  • Users enter and edit tabular numbers directly.
  • Totals must update as cells change.

Skip it when

  • Read-only data; use the data table.

Installation #

terminal
pnpm dlx shadcn@latest add @caliper/data-grid

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage #

Import it from your copy of the source. The example behind the preview comes with the source.

example.tsx
import { DataGrid } from "@/components/ui/data-grid"

The worked example comes with Pro

The 47-line example behind the preview opens here with a Pro or Team licence.

Checking your licence…

API reference #

DataGrid

component
PropTypeDefaultDescription
label *string—
value *Readonly<Record<string, string>>—
onValueChange *(value: Readonly<Record<string, string>>) => void—
rowsnumber20
columnsnumber8
columnLabelsreadonly string[]—Replaces the A, B, C headings.
classNamestring—

Accessibility #

It exposes grid, gridcell and status semantics, with aria-label, aria-rowcount, aria-colcount, aria-multiselectable, aria-selected and aria-hidden kept in step with state. Changes that matter are announced through a live region.

KeyBehaviour
↓Moves to the next item or value.
↑Moves to the previous item or value.
→Moves to the next item or value.
←Moves to the previous item or value.
PageDownMoves by a larger step, or to the next page.
PageUpMoves by a larger step, or to the previous page.
HomeJumps to the first item or the minimum.
EndJumps to the last item or the maximum.
TabMoves focus through the part's focusable elements.
EnterActivates the focused control.
DeleteRemoves the next character or the selected item.
BackspaceRemoves the previous character or item.
EscapeCloses or cancels, then returns focus to where it came from.

Motion #

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.