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/treemap
datachartnew
Loading…

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/treemap

Manually

  1. Install the dependencies.

    npm install motion
  2. Copy these files into your project. Shared files are skipped if you already have them.

    • components/silicon-ui/treemap/treemap.tsx
    • components/silicon-ui/treemap/treemap.module.css
  3. Install the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

Source codetsx
import { Treemap } from "@/components/silicon-ui/treemap/treemap";

API reference

PropTypeDefault
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) => stringvalue => grouped.format(value)
colorLabel

Names 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) => stringvalue => grouped.format(value)
colorDomain

Range of the color measure. Defaults to the range of the leaves.

[number, number]—
focus

Controlled id of the node that fills the view.

string—
defaultFocusstring—
onFocusChange(id: string) => void—
height

Height of the tiles in pixels.

number420
emptyLabelstring"No data yet"
refRef<HTMLElement>—
classNamestring—

Dependencies

npm
motion
Registry
silicon-motion-tokens