Treemap

A React component in Beamline's Charts & data-vis category.

Nested rectangles sized by value (spend by team, then service), squarified so tiles stay close to square: labels that fit or hide, hover and focus highlight, drill in with a click or Enter and out with Escape, Backspace or the breadcrumb, hatched chips for parts that were not measured, and a table of the current level.

Use it for

  • Part-to-whole over a hierarchy with drill-down: cloud spend by team and service, storage by folder, revenue by region and account.

Not for

Anatomy

  • title, description, breadcrumb (the way back up), table button
  • tiles (buttons): the current level's children
  • group header and nested tiles one level down (depth 2)
  • tile label and value (shown only when they fit)
  • readout (the hovered or focused tile's path, value and share)
  • unmeasured chips (hatched) under the plot

Variants

  • 0: depth: 1 (the current level only) · 2 (each tile shows its own children)
  • 1: level (controlled or not)

States

  • loading (skeleton)
  • empty
  • unmeasured parts (value null): left out of the area, listed as hatched chips that read “Not measured”
  • hovered / focused tile (ring, others dim)
  • drilled in (breadcrumb shows the path)
  • a tile with unmeasured parts inside carries a small hatched mark; the readout counts them
  • table view (the current level: value and share)
  • right-to-left: tiles mirror (largest at the start edge)

Keyboard

  • Tab focuses one tile; arrow keys move to the nearest tile in that direction (mirrored in right-to-left)
  • Enter or Space drills into a tile with children (or calls onSelect on a leaf)
  • Escape or Backspace goes up one level and refocuses the tile you came from; at the top Escape is left to the page
  • Breadcrumb items go straight to any level above

Motion

Tiles fade in once; drilling zooms the new level out of the chosen tile (one motion-out); instant under reduced motion.

Props

PropTypeDefaultDescription
dataTreemapNode—The root: { key, label, value?: number | null, children? }. A parent's value is the sum of its measured children.
format(value: number) => string—How values read: "$42.0k".
level / defaultLevel / onLevelChangestring—Key of the node whose children fill the view. Default the root.
depth1 | 2—Levels shown at once. Default 2.
heightnumber—Plot height. Default 320.
onSelect(node: TreemapNode, path: TreemapNode[]) => void—A leaf was chosen (click or Enter).
title / hideTitle / descriptionstring / boolean / ReactNode—The figure's name (a heading unless hidden) is always its accessible name.
tableboolean—Offer “View as table”. Default true.
loadingboolean—Skeleton of the chart's shape; keeps the frame's size.
actionsReactNode—Controls beside the legend (range, offset).
classNamestring—Lands on the figure.
classNamesChartClassNames—Frame, tooltip and slice-list parts as applicable to this chart.
style / refCSSProperties / Ref<HTMLElement>—The native chart figure; layout measurement refs stay internal.

Dependencies

motion

Import

import { Treemap } from "@/components/treemap/treemap";

Get it

Treemap is part of Beamline: 190 React components and screens your coding agent (Claude Code, Codex, Cursor or any MCP client) installs into your app through Beamline's MCP server, as a ready-built package or as plain React source you can change. $49 one payment (regular $200), no subscription, a year of updates, one licence for your whole team. Get Beamline · Connect your agent

More in Charts & data-vis

  • Activity heatmap: A calendar of daily counts, one cell per day on a sequential ramp: weeks across, weekdays down, month and weekday labels, a legend scale, hatched days…
  • Area chart: Amounts over time as filled areas: overlapping, stacked or as shares of 100%, five fills, two strokes, five curves, a range handle; gaps for missing…
  • Bar chart: Amounts by category as bars: columns or rows, grouped, stacked or as shares, reference lines, five looks (rounded, cells, trace, isometric, monospace), a…
  • Composed chart: Different measures on one time axis: bars, lines and areas per series, a left and a right value axis with their own formats, and reference lines.
  • Gauge: One value against a known range: a semicircle, a 270° dial or a full ring, filled or with a needle, coloured bands with their names (healthy, busy…
  • Line chart: Values over time as lines: curves, point markers, dashed series for forecasts, reference lines for limits and targets, an optional zero baseline and a…
  • Pie chart: A few shares of a whole as a pie or donut, with spaced slices, percent labels, a centre readout and a list of every slice with value and share; hovering…
  • Radar chart: A few series compared across the same five to eight dimensions as polygons on a polygon or circle grid; hover or arrow keys pick a dimension and read…
  • Radial chart: Progress of a few measures toward their targets as concentric rings, full or half circle, with a centre readout and a list of each ring's value, target…
  • Ridgeline: Distributions per group as overlapping density ridges (response time by region, order size by plan): an overlap control, median and p95 readouts per row…
  • Sankey chart: Flows between stages as bands whose width is the amount: sources to pages to outcomes, budgets to teams; hovering or focusing a node lights its flows and…
  • Slope chart: Change between two points in time per item, by value or by rank: labels on both sides that never collide, rising and falling told by the end marker (▲ ▼)…
  • Sparkline: A compact trend beside its value: point along it or focus it and use ← → to read each point; nulls are gaps. TrendLine is the bare line.
  • Streamgraph: Stacked flows over time around a centre baseline, with silhouette, wiggle, expand (shares) and zero offsets: a legend that turns layers on and off, a…
  • Waffle chart: Units of a whole as a grid of cells by category (seats used of a plan, tickets by channel): a 10×10 grid by default, hatched cells for units whose…