Treemap
FreeNested rectangles sized by value, with drill-down.
pnpm dlx shadcn@latest add https://caliperui.site/r/treemap.json| Item | Group | Value | Share |
|---|---|---|---|
| Figma files | Design | 42 | 23.9% |
| Exports | Design | 18 | 10.2% |
| Builds | Engineering | 64 | 36.4% |
| Logs | Engineering | 30 | 17.0% |
| Operations | All | 22 | 12.5% |
When to use #
Use it for
- Showing parts of a whole across two levels.
- Many categories where a pie would be unreadable.
Skip it when
- Precise comparison of similar values.
Installation #
pnpm dlx shadcn@latest add https://caliperui.site/r/treemap.json
Adds its 3 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage #
This is the code behind the preview above. It is built from Treemap and layoutTreemap.
import { Treemap } from "@/components/ui/treemap" export function StorageTreemap() { return ( <div className="w-full max-w-xl"> <Treemap label="Storage by team" unit="GB" data={[ { id: "design", label: "Design", children: [{ id: "d1", label: "Figma files", value: 42 }, { id: "d2", label: "Exports", value: 18 }] }, { id: "eng", label: "Engineering", children: [{ id: "e1", label: "Builds", value: 64 }, { id: "e2", label: "Logs", value: 30 }] }, { id: "ops", label: "Operations", value: 22 }, ]} /> </div> ); }
API reference #
Treemap
component
layoutTreemap
component
No props of its own; it accepts the native props of its root element.
Accessibility #
It exposes group and status semantics, with aria-label, aria-busy, aria-hidden, aria-current and aria-pressed kept in step with state. Changes that matter are announced through a live region.
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.