Treemap
A squarified treemap: click to drill and the tiles grow to fill the view, with a breadcrumb back and metrics that morph every tile.
npx shadcn@latest add @silicon-ui/treemapInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/treemapManually
Install the dependencies
npm install motionCopy these files into your project
- components/silicon-ui/treemap/treemap.tsx
- components/silicon-ui/treemap/treemap.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
data*The root. Its label names the whole in the first breadcrumb. | TreemapNode | — |
label*What the whole is, such as "Revenue". Names the chart for assistive technology. | string | — |
formatValue | (value: number) => string | value => grouped.format(value) |
colorLabelNames the shading measure in the tooltip and scale, such as "Growth". Tiles take the hue of their top level branch and grow deeper with the measure. Leave it out to draw every tile at one depth. | string | — |
formatColor | (value: number) => string | value => grouped.format(value) |
colorDomainRange of the color measure. Defaults to the range of the leaves. | [number, number] | — |
focusControlled id of the node that fills the view. | string | — |
defaultFocus | string | — |
onFocusChange | (id: string) => void | — |
heightHeight of the tiles in pixels. | number | 420 |
emptyLabel | string | "No data yet" |
ref | Ref<HTMLElement> | — |
className | string | — |
Dependencies
- npm
- motion
- Registry
- silicon-motion-tokens