Skip to content
Haze UI

Table

Data table built from columns and rows with tabular numbers, optional striping, and a floating card variant.

pnpm dlx shadcn@latest add @haze/table
Open preview in a new tab
Liveno JavaScript

When to use

  • Comparing the same few fields across many records, such as invoices or deployments
  • Numeric columns that should line up on the right with tabular figures
  • Embedding a card-styled grid cleanly beneath transparent headers inside a Frame

When not to use

  • Page layout; use grid or flex instead
  • Data that needs sorting, filtering, selection or pagination; use sortable-data-table
  • Two or three fields per record on narrow screens; the item component stacks better

Installation

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

pnpm dlx shadcn@latest add @haze/table
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
caption*string–Title of the table. Also the aria-label of the scroll region.
hideCaptionbooleanfalseMoves the caption to screen readers only.
columns*{ key: string; label: string; align?: "left" | "right" }[]–Header cells in order. align right also turns on tabular figures in the cells.
rows*Record<string, string>[]–One object per row; each column reads row[column.key]. Values are plain strings.
stripedbooleanfalseShades every second body row for long tables.
variant"default" | "card""default"default frames the full table in a card; card renders transparent headers over a rounded elevated body grid.
rowHeaderstring–Key of the column whose cells render as <th scope="row">.
classstring–Extra classes on the outer panel.

Keyboard interactions

Tab, then Arrow keys
Focus the scroll region, then scroll it sideways or vertically

Accessibility

  • Uses a real table with <caption>, scope="col" headers and optional scope="row" headers.
  • The scroll region is focusable and named by the caption so keyboard users can scroll wide tables.
  • Cells hold plain strings so status meaning stays readable without relying on color.

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 "Table" with `npx shadcn@latest add @haze/table`. 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 Table from "@/components/haze/ui/table.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/table.md

  • Customize with real content

    Adapt the Haze table ui for our product. Replace the demo values of these props with our real content: caption, hideCaption, columns, rows, striped, variant, rowHeader, class. Keep the layout, the heading level rules and these accessibility details: Uses a real table with <caption>, scope="col" headers and optional scope="row" headers. The scroll region is focusable and named by the caption so keyboard users can scroll wide tables. Cells hold plain strings so status meaning stays readable without relying on color. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using table, check it fits: use it when comparing the same few fields across many records, such as invoices or deployments; numeric columns that should line up on the right with tabular figures; embedding a card-styled grid cleanly beneath transparent headers inside a frame. Avoid it when page layout; use grid or flex instead; data that needs sorting, filtering, selection or pagination; use sortable-data-table; two or three fields per record on narrow screens; the item component stacks better. Alternatives: @haze/sortable-data-table, @haze/frame, @haze/item.

Dependencies

  • @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