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$210.0K17.9%
Technology / MSFT$190.0K16.2%
Technology / NVDA$130.0K11.1%
Healthcare / LLY$128.0K10.9%
Healthcare / UNH$85.0K7.2%
Healthcare / JNJ$45.0K3.8%
Finance / JPM$80.0K6.8%
Finance / V$95.0K8.1%
Finance / BAC$30.0K2.6%
Energy / XOM$74.0K6.3%
Energy / CVX$62.0K5.3%
Energy / SHEL$44.0K3.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?
"top" | "right" | "bottom" | "left"
top

TreemapLegend

className?
string
—
showValues?
boolean
false

Updated