> Native Solid 2 fork of [solid-recharts](https://github.com/yumemi-thomas/solid-recharts) (MIT, © Thomas Guehenneux), derived from [Recharts](https://github.com/recharts/recharts) (MIT, © recharts). Adapted documentation; neither project endorses this fork.

# Treemap

`Treemap` is a self-contained hierarchical chart that packs a tree of data into nested rectangles. Each rectangle's area is proportional to its data value, making it easy to spot large and small items across hierarchies. It is not placed inside another chart container.

```tsx
() => {

	const data = [

		{ name: "Themes", children: [{ name: "Button", size: 1302 }, { name: "Dialog", size: 2400 }, { name: "Table", size: 1800 }] },

		{ name: "Primitives", children: [{ name: "Menu", size: 3100 }, { name: "Select", size: 2200 }] },

		{ name: "Charts", children: [{ name: "Line", size: 1500 }, { name: "Pie", size: 900 }] },

	];

	return <ResponsiveContainer width="100%" height={300} initialDimension={{ width: 560, height: 300 }}>

		<Treemap
			data={data}
			dataKey="size"
			nameKey="name"
			stroke="var(--color-background)"
			colorPanel={["var(--accent-9)", "var(--teal-9)", "var(--amber-9)", "var(--crimson-9)", "var(--violet-9)", "var(--gray-9)"]}
		/>

	</ResponsiveContainer>;

}
```

## Props

| Prop              | Type                 | Default         | Description                                           |
| ----------------- | -------------------- | --------------- | ----------------------------------------------------- |
| `data`            | `object[]`           | —               | Array of top-level nodes; each may have `children`    |
| `dataKey`         | `string \| function` | `"value"`       | Key or function to read each node's numeric value     |
| `nameKey`         | `string \| function` | `"name"`        | Key to read each node's name / label                  |
| `width`, `height` | `number \| "%"`      | —               | Fixed size or percentage inside `ResponsiveContainer` |
| `aspectRatio`     | `number`             | `0.5*φ` (\~1.6) | Squarified layout aspect ratio target                 |
| `type`            | `"flat" \| "nest"`   | `"flat"`        | Render the whole tree or nested drill-down mode       |
| `nodeGap`         | `number`             | `0`             | Space between sibling rectangles                      |
| `nodeInset`       | `number`             | `0`             | Padding inside each parent rectangle                  |

The base props follow the Recharts 3.9.2 `Treemap` API (reference commit `b3451050`) that solid-recharts tracks; see the [Recharts Treemap reference](https://recharts.org/en-US/api/Treemap). The [next-suite release scope](/charts/docs/overview/releases) lists selected adaptations, not full Recharts 3.10.1 parity.

## Notes

- **Data shape:** Each node can have a `children` property (array of child nodes). Leaf nodes should have a numeric `dataKey` value; parent nodes' values are rolled up from their children.
- **Animation:** Only entry animation is implemented: nodes slide in from the left on mount. Update animation is not ported, and `Treemap` has no `isUpdateAnimationActive` prop.
- **nest mode:** Set `type="nest"` to render an interactive treemap where clicking a parent node drills in; a breadcrumb strip at the bottom navigates back up.
- **Tooltip:** Treemap supports item-type tooltips; hover a rectangle to see its details.

## See also

- [ResponsiveContainer](/charts/docs/guides/responsive-and-ssr) — fluid sizing
- Tooltip — hover info
