Skip to content
Haze UI

Tree Table

A hierarchical native table with collapsible branches, inherited selection, and mixed parent checkboxes.

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

When to use

  • A file listing needs names and sizes alongside a nested hierarchy.
  • Selecting a folder should include its descendant files.

When not to use

  • The listing is flat and needs many sortable fields. Use sortable-data-table.

Installation

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

pnpm dlx shadcn@latest add @haze/tree-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
id*string–Unique table ID.
captionstring–Visible and accessible table name.
nodes{ label: string; value?: string; children?: TreeNode[] }[]–Hierarchical names and secondary values in display order.
classstring–Additional classes on the component wrapper.

Keyboard interactions

Arrow RightLeft
Expand a branch, move toward its children, collapse it or focus its parent.
Arrow UpDown
Move between visible expandable branches.

Accessibility

  • The native table remains fully expanded without scripts. Collapsing a branch hides its descendants while retaining their selection.
  • Checkbox changes propagate downward and mixed states recompute upward. Branch controls support Arrow keys, and captions name the scrollable 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 "Tree Table" with `npx shadcn@latest add @haze/tree-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 TreeTable from "@/components/haze/ui/tree-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/tree-table.md

  • Customize with real content

    Adapt the Haze tree-table ui for our product. Replace the demo values of these props with our real content: id, caption, nodes, class. Keep the layout, the heading level rules and these accessibility details: The native table remains fully expanded without scripts. Collapsing a branch hides its descendants while retaining their selection. Checkbox changes propagate downward and mixed states recompute upward. Branch controls support Arrow keys, and captions name the scrollable table. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using tree-table, check it fits: use it when a file listing needs names and sizes alongside a nested hierarchy.; selecting a folder should include its descendant files.. Avoid it when the listing is flat and needs many sortable fields. use sortable-data-table.. Alternatives: @haze/file-tree, @haze/sortable-data-table.

Dependencies

  • npm: @lucide/astro
  • @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