Skip to content
Haze UI

Data Grid

Edit a native table with keyboard movement, drag or Shift ranges, clipboard paste, fill-down, undo, and redo.

pnpm dlx shadcn@latest add @haze/data-grid
Open preview in a new tab
Livesmall script

When to use

  • People edit a small to medium budget or inventory in place.
  • Copying rectangular values between the grid and a spreadsheet speeds up entry.

When not to use

  • The dataset needs server paging or virtualization. Use a data-source integration around a paged table.

Installation

Add the Haze registry to components.json once, then install Data Grid with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/data-grid
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique table ID and keyboard instructions prefix.
captionstring–Visible name for the editable dataset.
columnsColumn[]–Column keys, labels, numeric flags and optional editable false.
rowsRecord<string, string | number>[]–Initial values. The browser dispatches changes for the host to persist.
classstring–Additional classes on the component wrapper.

Keyboard interactions

ArrowsHomeEnd
Move the active cell. Hold Shift to extend the selected range.
EnterF2Escape
Edit the cell, commit, or cancel.
ControlCommand C, V, Z
Copy, paste or undo. Shift Z redoes.

Accessibility

  • Only one data cell enters the tab order. Arrow keys move through cells, Shift extends a rectangular range, and Enter opens a labelled input.
  • Numeric cells reject empty and nonfinite edits. All edits emit haze:grid-change for application persistence. Static markup exposes the full native table.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Data Grid" with `npx shadcn@latest add @haze/data-grid`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import DataGrid from "@/components/haze/ui/data-grid.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/data-grid.md

  • Customize with real content

    Adapt the Haze data-grid ui for our product. Replace the demo values of these props with our real content: id, caption, columns, rows, class. Keep the layout, the heading level rules and these accessibility details: Only one data cell enters the tab order. Arrow keys move through cells, Shift extends a rectangular range, and Enter opens a labelled input. Numeric cells reject empty and nonfinite edits. All edits emit haze:grid-change for application persistence. Static markup exposes the full native table. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using data-grid, check it fits: use it when people edit a small to medium budget or inventory in place.; copying rectangular values between the grid and a spreadsheet speeds up entry.. Avoid it when the dataset needs server paging or virtualization. use a data-source integration around a paged table.. Alternatives: @haze/sortable-data-table, @haze/inline-edit, @haze/table.

Dependencies

  • npm: @lucide/astro
  • @haze/sortable-data-table
  • @haze/button
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog