Treemap

Proportional tiles that morph with your data, with value and share tooltips.

Preview

Portfolio allocation

Demo data

  • Technology
  • Healthcare
  • Finance
  • Energy
Portfolio allocation data
ItemValueShare of totalDetails
Technology / AAPL$210K17.9%
Technology / MSFT$190K16.2%
Technology / NVDA$130K11.1%
Healthcare / LLY$128K10.9%
Healthcare / UNH$85K7.2%
Healthcare / JNJ$45K3.8%
Finance / JPM$80K6.8%
Finance / V$95K8.1%
Finance / BAC$30K2.6%
Energy / XOM$74K6.3%
Energy / CVX$62K5.3%
Energy / SHEL$44K3.8%

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/treemap

API Reference

Treemap

data
readonly TreemapNode[]

Flat leaves or nested groups. Tile area uses leaf values; groups sum their descendants.

—
label?
string
—
formatValue?
((value: number) => string)
—
colors?
readonly string[]

Top-level palette; nodes can override their inherited color and textColor.

—
textColor?
string
—
activeId?
string | null
—
defaultActiveId?
string | null
—
onActiveChange?
((id: string | null) => void)
—
className?
string
—

TreemapPlot

className?
string

Sets the plot height; default 20rem. The layout follows its measured dimensions.

—
tileClassName?
string
—
renderTile?
((tile: TreemapTile) => ReactNode)

Return presentation content only; each tile already owns its button and accessible name.

—

TreemapTooltip

className?
string
—
side?
"bottom" | "left" | "right" | "top"
top

TreemapLegend

className?
string
—
showValues?
boolean
false

Updated