Data grid
A spreadsheet-style grid with editable cells and formulas.
A1
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Budget line | October | November | December | Quarter | Share % | |
| 2 | Salaries | 84,000 | 84,000 | 86,500 | 254,500 | 63.28 | |
| 3 | Cloud hosting | 12,400 | 13,150 | 14,900 | 40,450 | ||
| 4 | Software licences | 6,200 | 6,200 | 6,900 | 19,300 | ||
| 5 | Marketing | 9,500 | 15,200 | 11,800 | 36,500 | ||
| 6 | Travel | 2,100 | 3,400 | 5,200 | 10,700 | ||
| 7 | Office | 4,300 | 4,300 | 4,300 | 12,900 | ||
| 8 | Contractors | 7,800 | 9,100 | 6,400 | 23,300 | ||
| 9 | Training | 800 | 1,500 | 2,200 | 4,500 | ||
| 10 | |||||||
| 11 | Total | 127,100 | 136,850 | 138,200 | 402,150 | ||
| 12 | Monthly average | 15,887.5 | 17,106.25 | 17,275 | 134,050 | ||
| 13 | |||||||
| 14 |
When to use
- Users enter and edit tabular numbers directly.
- Totals must update as cells change.
When not to use
- 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.
API reference
DataGrid
7 props
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—
Keyboard
- ↓
- 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.
- PageDown
- Moves by a larger step, or to the next page.
- PageUp
- Moves by a larger step, or to the previous page.
- Home
- Jumps to the first item or the minimum.
- End
- Jumps to the last item or the maximum.
- Tab
- Moves focus through the part's focusable elements.
- Enter
- Activates the focused control.
- Delete
- Removes the next character or the selected item.
- Backspace
- Removes the previous character or item.
- Escape
- Closes or cancels, then returns focus to where it came from.
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.
Notes for AI
Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.
/docs/components/data-grid.mdThe index of every part is at /llms.txt.