Treemap
Squarified tiles for hierarchical part-to-whole data, shown two levels at a time with branch zoom.
import { Treemap } from '@uthereal/ui/treemap'Treemap playground
| Path | Value | Share of parent | Growth |
|---|---|---|---|
| North America | $21.4M | 48% | +26% |
| North America / United States | $18.4M | 86.1% | +26% |
| North America / United States / Team | $4.0M | 22% | +20% |
| North America / United States / Business | $7.0M | 38% | +25% |
| North America / United States / Enterprise | $7.4M | 40% | +30% |
| North America / Canada | $2.4M | 11% | +21% |
| North America / Canada / Team | $517.0K | 22% | +15% |
| North America / Canada / Business | $893.0K | 38% | +20% |
| North America / Canada / Enterprise | $940.0K | 40% | +25% |
| North America / Mexico | $610.0K | 2.9% | +43% |
| North America / Mexico / Team | $134.2K | 22% | +37% |
| North America / Mexico / Business | $231.8K | 38% | +42% |
| North America / Mexico / Enterprise | $244.0K | 40% | +47% |
| Europe | $14.0M | 31.5% | +26% |
| Europe / Germany | $4.1M | 29.4% | +30% |
| Europe / Germany / Team | $906.4K | 22% | +24% |
| Europe / Germany / Business | $1.6M | 38% | +29% |
| Europe / Germany / Enterprise | $1.6M | 40% | +34% |
| Europe / United Kingdom | $3.9M | 27.6% | +19% |
| Europe / United Kingdom / Team | $849.2K | 22% | +13% |
| Europe / United Kingdom / Business | $1.5M | 38% | +18% |
| Europe / United Kingdom / Enterprise | $1.5M | 40% | +23% |
| Europe / France | $2.2M | 16% | +24% |
| Europe / France / Team | $492.8K | 22% | +18% |
| Europe / France / Business | $851.2K | 38% | +23% |
| Europe / France / Enterprise | $896.0K | 40% | +28% |
| Europe / Netherlands | $1.3M | 9.4% | +33% |
| Europe / Netherlands / Team | $288.2K | 22% | +27% |
| Europe / Netherlands / Business | $497.8K | 38% | +32% |
| Europe / Netherlands / Enterprise | $524.0K | 40% | +37% |
| Europe / Nordics | $1.6M | 11.3% | +28% |
| Europe / Nordics / Team | $347.6K | 22% | +22% |
| Europe / Nordics / Business | $600.4K | 38% | +27% |
| Europe / Nordics / Enterprise | $632.0K | 40% | +32% |
| Europe / Spain | $890.0K | 6.4% | +38% |
| Europe / Spain / Team | $195.8K | 22% | +32% |
| Europe / Spain / Business | $338.2K | 38% | +37% |
| Europe / Spain / Enterprise | $356.0K | 40% | +42% |
| Asia Pacific | $7.0M | 15.7% | +37% |
| Asia Pacific / Japan | $2.8M | 39.5% | +35% |
| Asia Pacific / Japan / Team | $607.2K | 22% | +29% |
| Asia Pacific / Japan / Business | $1.0M | 38% | +34% |
| Asia Pacific / Japan / Enterprise | $1.1M | 40% | +39% |
| Asia Pacific / Australia | $1.7M | 24.2% | +23% |
| Asia Pacific / Australia / Team | $371.8K | 22% | +17% |
| Asia Pacific / Australia / Business | $642.2K | 38% | +22% |
| Asia Pacific / Australia / Enterprise | $676.0K | 40% | +27% |
| Asia Pacific / India | $980.0K | 14% | +60% |
| Asia Pacific / India / Team | $215.6K | 22% | +54% |
| Asia Pacific / India / Business | $372.4K | 38% | +59% |
| Asia Pacific / India / Enterprise | $392.0K | 40% | +64% |
| Asia Pacific / Singapore | $720.0K | 10.3% | +31% |
| Asia Pacific / Singapore / Team | $158.4K | 22% | +25% |
| Asia Pacific / Singapore / Business | $273.6K | 38% | +30% |
| Asia Pacific / Singapore / Enterprise | $288.0K | 40% | +35% |
| Asia Pacific / South Korea | $840.0K | 12% | +47% |
| Asia Pacific / South Korea / Team | $184.8K | 22% | +41% |
| Asia Pacific / South Korea / Business | $319.2K | 38% | +46% |
| Asia Pacific / South Korea / Enterprise | $336.0K | 40% | +51% |
| Latin America | $2.1M | 4.8% | +43% |
| Latin America / Brazil | $1.2M | 58.5% | +51% |
| Latin America / Brazil / Team | $272.8K | 22% | +45% |
| Latin America / Brazil / Business | $471.2K | 38% | +50% |
| Latin America / Brazil / Enterprise | $496.0K | 40% | +55% |
| Latin America / Chile | $330.0K | 15.6% | +29% |
| Latin America / Chile / Team | $72.6K | 22% | +23% |
| Latin America / Chile / Business | $125.4K | 38% | +28% |
| Latin America / Chile / Enterprise | $132.0K | 40% | +33% |
| Latin America / Colombia | $290.0K | 13.7% | +54% |
| Latin America / Colombia / Team | $63.8K | 22% | +48% |
| Latin America / Colombia / Business | $110.2K | 38% | +53% |
| Latin America / Colombia / Enterprise | $116.0K | 40% | +58% |
| Latin America / Argentina | $260.0K | 12.3% | +14% |
| Latin America / Argentina / Team | $57.2K | 22% | +8% |
| Latin America / Argentina / Business | $98.8K | 38% | +13% |
| Latin America / Argentina / Enterprise | $104.0K | 40% | +18% |
Overview
A treemap renders a hierarchy of parts as squarified tiles sized by value, displaying two levels at once. Top-level branches divide the stage, and each branch lays out its children beneath a header bar with its name and subtotal when space permits. Clicking a branch or pressing Enter zooms into that branch; the breadcrumb bar above navigates back up and displays the current view total. Exploring a tile rings it, dims sibling branches, and shows a tooltip with its full path, formatted value, and share of its parent. A native data table lists every node and path.
Use a treemap when relative proportions across a nested hierarchy matter more than exact comparisons. For exact comparisons across flat categories, use a bar chart. For one level of a few parts, use a donut chart.
Usage
import { Treemap } from '@uthereal/ui/treemap'
export function Revenue() {
return (
<Treemap
title="Revenue by region"
rootLabel="All regions"
nodes={[
{
id: 'emea',
label: 'EMEA',
children: [
{ id: 'de', label: 'Germany', value: 42 },
{ id: 'fr', label: 'France', value: 28 },
],
},
{ id: 'apac', label: 'APAC', value: 51 },
]}
onFocusChange={(focus) => console.log(focus)}
/>
)
}Leaves carry a nonnegative value; branches carry children and are sized by the sum of their descendants. Trees support up to 200 nodes and four nesting levels below the root. Set compact: true to abbreviate large values (such as $44.5M), and pass focus and onFocusChange to control the zoomed branch externally.
Examples
Pre-zoomed branch without secondary shading
Set defaultFocus to open directly on a specific branch ID, displaying its parent trail in the breadcrumb bar. Omitting colorLabel renders single-measure hue tinting per top-level branch.
| Path | Value | Share of parent |
|---|---|---|
| EMEA | 105 | 38.9% |
| EMEA / Germany | 42 | 40% |
| EMEA / France | 28 | 26.7% |
| EMEA / United Kingdom | 35 | 33.3% |
| Americas | 114 | 42.2% |
| Americas / United States | 96 | 84.2% |
| Americas / Brazil | 18 | 15.8% |
| APAC | 51 | 18.9% |
Behavior
Tiles lay out with a 2 px gap and inherit a tint of their top-level branch hue across the first four branches; later top-level branches remain neutral ink so regions retain consistent identity while zooming. When colorLabel is set, each leaf's color value (and each branch's size-weighted mean) shades tiles across five stepped levels over colorDomain (or the leaf range), adding a stepped scale below the stage, a tooltip row, and a table column formatted with colorFormat.
Shares in tooltips, announcements, and the data table are always relative to the node's parent (shareOfLabel). Clicking a branch zooms into it; clicking or tapping a leaf focuses its readout. When every node sums to zero, the stage displays emptyLabel ("No data yet").
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
title | stringDefault: "Treemap" | Figure title. It names the chart for assistive technology and captions the data table. |
description | string— | One or two sentences on what the chart shows, below the title; omit it when the title says enough. |
tableToggle | booleanDefault: false | Show a button that reveals the data table. The table is always available to assistive technology. |
tableLabel | stringDefault: "Data table" | Name of the data table button. |
pointLabel | stringDefault: "{path}, {value}, {share} of {parent}" | Announced for the tile under the pointer or keyboard focus. {path}, {label}, {value}, {share} (of its parent) and {parent} are filled in; the shading measure follows when there is one. |
valueFormat | NumberFormat— | How values appear in the tooltip, table and axis: decimal, percent or currency, with fraction digits. Axis ticks are compacted (12.9K). |
locale | string— | BCP 47 locale for numbers and dates. Omit it to inherit the application locale (en-US by default). |
compact | booleanDefault: false | Abbreviate values on tiles, the total, the tooltip and the data table (12.9K, $44.5M), as the formatters of Arc’s demo do. |
colorFormat | TreemapColorFormat— | How the shading measure is written: decimal or percent, fraction digits and signDisplay (exceptZero writes +8%). Omitted, it shows at most one decimal. |
emptyLabel | stringDefault: "No data yet" | Shown over the stage when every value is zero. |
nodes | TreemapNode[]Default: [{"id":"emea","label":"EMEA","children":[{"id":"de","label":"Germany","value":42},{"id":"fr","label":"France","value":28},{"id":"uk","label":"United Kingdom","value":35}]},{"id":"americas","label":"Americas","children":[{"id":"us","label":"United States","value":96},{"id":"br","label":"Brazil","value":18}]},{"id":"apac","label":"APAC","value":51}] | The top-level tiles: each an id, a label and either a value (a leaf, zero or more) or children (a branch, sized by their sum). Up to 200 nodes and four levels below the top. |
rootLabel | stringDefault: "All" | Names the whole in the first breadcrumb. |
colorLabel | string— | Names the shading measure (each leaf’s color). Set it to shade tiles deeper with the measure, with a stepped scale under the stage. |
colorDomain | array— | Range of the shading measure. Omit it to use the range of the leaves. |
shareOfLabel | stringDefault: "{share} of {parent}" | Tooltip line under a tile. {share} and {parent} are filled in. |
defaultFocus | string— | The id of a branch to show first. Omit it to show the top level. Later argument edits do not reset an existing instance. |
breadcrumbLabel | stringDefault: "Path" | Accessible name of the breadcrumb navigation. |
categoryLabel | stringDefault: "Path" | Header of the path column in the data table. |
valueLabel | stringDefault: "Value" | Header of the value column in the data table. |
shareLabel | stringDefault: "Share of parent" | Header of the share column in the data table (each node’s share of its parent). |
height | integerDefault: 420 | Height of the tiles in pixels (160–800). |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | TreemapTheme— | Color mode, accent, and tokens, including the chart palette. See Theming. |
motion | none | subtle | expressiveDefault: "subtle" | Draw-in and zoom animation preset. System reduced-motion preferences take precedence. |
motionOptions | ChartMotionOptions— | draw (tiles growing from their centers, largest first, when a quarter of the chart is in view; Arc's .9 s spring when omitted) and morph (the zoom carry; Arc's .62 s spring when omitted): a tween with a duration (ms) or a spring. |
dir | ltr | rtl— | Reading direction of the breadcrumb and labels. Omit it to inherit the page direction. |
React integration
| Prop | Purpose |
|---|---|
focus | Controlled branch ID currently zoomed into, or null for the top level |
onFocusChange | Fires with the new branch ID (or null) on zoom, in both modes |
preset | Application defaults, overridden by explicit instance props |
tokens | CSS variables applied after the typed theme |
ref | Ref forwarded to the root <figure> |
className, style | Applied to the root <figure> |
| Native attributes | id, data-*, and remaining <figure> attributes forwarded to the root |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Focus breadcrumb buttons, then the treemap stage |
Arrow keys | Move to the nearest tile in the pressed direction |
Home, End | Jump to the first or last tile in the current view |
Enter, Space | Zoom into the focused branch (focusing its first child tile) |
Backspace, Escape | Zoom out to the parent branch, or clear focus at the top level |
The chart renders a <figure> named by title and linked via aria-details to a native data table listing every node's path, value, share of parent, and optional shading measure. The breadcrumb renders a <nav> named by breadcrumbLabel, with aria-current on the active level. Individual SVG tiles are hidden from assistive technology.
The plot is a single tab stop without a separate outer focus box; the first arrow key rings the first tile. Each focused tile announces politely via pointLabel (plus the shading measure when enabled). Under forced-colors, system colors apply.
Motion and theming
When 25% of the chart enters the viewport, tiles scale from their centers largest-first on a 900 ms spring (motionOptions.draw); tile geometry scales without distorting text, and server-rendered markup is final. Zoom transitions carry tiles on a 620 ms spring (motionOptions.morph, bounce 0.06), mapping entering and exiting tiles through the zoomed branch rectangle while breadcrumbs slide in and the view total rolls into place. Tile color changes transition over 480 ms, and the tooltip glides on a snappy spring. motion="none" and prefers-reduced-motion: reduce disable draw-in, zoom carries, and transitions.
theme accepts a mode, an accent, and semantic tokens including the chart palette. An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, Treemap is a leaf with no actions. The zoomed branch is host state stored at /components/instance-<id>/focus, initialized from defaultFocus (or null for the top level). The host updates nodes through composition updates. See Building with agents.
{
"type": "Treemap",
"props": {
"title": "Spend by team",
"nodes": [
{ "id": "eng", "label": "Engineering", "value": 412 },
{ "id": "sales", "label": "Sales", "value": 268 }
]
},
"children": []
}