Skip to content
Alea0.1
Pro
  1. Alea
  2. Components
  3. Charts
  4. Treemap

ChartsAlea Pro

Treemap

Parts of a whole when there are many: each tile is sized by its share, laid out to stay square.

import { Treemap } from '@alea/pro';

Examples

Storage by folder

Each tile's area is its share. Tiles stay as square as possible.

Storage used
Photos48 GBVideo31 GBDesign files22 GBBackups14 GBDocuments9 GBMusic7 GB

Tokens

The design tokens this component reads, with their value in the current theme. Override any of them to restyle it.

Color

  • --alea-accent-on…
  • --alea-focus…

Type

  • --alea-font-family-body…

Motion

  • --alea-motion-duration-fast…
  • --alea-motion-duration-slow…
  • --alea-motion-spring…

Props

Treemap props

Parts of a whole when there are many: each tile's area is its share (storage by folder, revenue by product).

PropTypeDefaultDescription
datarequired{ label: string; value: number; color?: string | undefined; }[]-Items with a value; each gets an area proportional to it.
classNamestring-Extra class names for the root element.
descriptionReactNode-One sentence on what the data shows; read before the chart.
heightnumber300Height in px. Default 300.
isLoadingboolean-Shows a shimmering placeholder while data loads.
showTablebooleantrueShows the table toggle. Default true.
titleReactNode-The title shown above it and read by screen readers.
valueFormat((v: number) => string)-Formats values (axis, tooltip, table).

Specs

Generated from the source: the variants in the types, the states and tokens in the CSS, and the motion patterns that apply. The grids render the real component in both themes; the numbers are measured from the page.

States
Keyboard focusPressed (CSS)
Dark and light
Every color comes from theme tokens, so it follows data-theme (and presets like Graphite) on the page or any wrapper. Contrast is checked in both themes.
Styling hooks
.alea-chart-svgwrap.alea-chart-svg.alea-treemap.alea-treemap-tile.alea-treemap-label.alea-treemap-value
Data attributes
data-dim

Accessibility

  • The chart is a figure named by its title and described by its description; the picture has a text summary.
  • Tab to the chart, then arrow keys move through the data and each value is announced; Escape leaves.
  • The table toggle shows the same data as a real table for everyone who can't use the picture.

Keyboard

KeyDoes
TabFocuses the chart
Left or Right arrowPrevious or next value
Home or EndFirst or last value
EscapeClears the selection

Do and don't

Do

  • Use it for many parts of one whole, like spend by team.
  • Label the larger tiles and keep the rest in the tooltip and the table.

Don't

  • Don't use it to compare exact values: use a bar chart.
  • Don't use it for negative values.
Tested with axe, keyboard and screen reader roles