Treemap chart
A whole as nested tiles, each as large as its value. Press a group to zoom in until it fills the chart; the hovered tile stays bright while the rest step back, and new data moves every tile from where it is.
Examples
Storage
Groups with their tiles inside, coloured by group, with each tile’s name and size where they fit. Press a kind, or a tile in it, to zoom in until it fills the chart; TreemapPath above it, or Escape, zooms back out. Another month moves every tile from where it is.
Flat
Rows with no children are one level of tiles, each in the next of the chart’s colours, with nothing to zoom into.
Colour by value
color gives a tile a colour of its own from its row, here red for a notebook written in less than last week. Its label stays readable on any colour.
Zoom
zoom and onZoomChange hold the part in view as the path of names to it, so controls of your own and the chart’s presses agree, and new data keeps it.
Installation
npx shadcn@latest add https://kinoui.com/r/treemap-chart.json- Files
lib/dates.tslib/chart-math.tslib/chart-scale.tslib/chart-frame.tslib/refs.tslib/reduce-motion.tslib/resize.tslib/live.tsxlib/chart-live.tslib/chart-live-clock.tsxlib/scroll.tslib/swap.tsxlib/popup.tslib/glide.tsxlib/keys.tsxcomponents/kino/kbd.tsxcomponents/kino/tooltip.tsxlib/cut.tsxlib/number-format.tslib/roll.tsxlib/run-progress.tscomponents/kino/animated-number.tsxlib/announce.tscomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/controllable.tslib/chart-root.tsxlib/chart-state.tslib/chart-agent.tslib/chart-base.tsxlib/chart-cartesian-reader.tslib/chart-cartesian.tsxlib/chart-list.tsxlib/chart-list-reader.tslib/chart-tree-reader.tslib/chart-flow-reader.tslib/chart-grid-reader.tslib/highlight.tscomponents/kino/chart.tsxlib/chart-tiles.tscomponents/kino/separator.tsxlib/list-rows.tsxlib/grip.tslib/panel.tsxcomponents/kino/menu.tsxcomponents/kino/breadcrumb.tsxlib/chart-tree-path.tsxlib/placeholder.tscomponents/kino/treemap-chart.tsx- Packages
@ui-sdk/core@ui-sdk/reactclass-variance-authorityd3-arrayd3-hierarchy- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
The CLI keeps any of these colours your project already has, such as the chart colours shadcn init writes. To use Kino’s, set them in your global CSS:
:root { --chart-1: oklch(0.42 0.1 248); --chart-2: oklch(0.53 0.12 222); --chart-3: oklch(0.6 0.11 185); --chart-4: oklch(0.65 0.17 132); --chart-5: oklch(0.72 0.154 106.7); --chart-accent: oklch(0.795 0.171 71.2);}.dark { --chart-1: oklch(0.6 0.15 255); --chart-2: oklch(0.7 0.13 222); --chart-3: oklch(0.79 0.13 185); --chart-4: oklch(0.82 0.15 128); --chart-5: oklch(0.72 0.154 106.7); --chart-accent: oklch(0.795 0.171 71.2);}API reference
TreemapChart
The chart: a <figure> named by label, which lays out and draws the tiles and holds the chart’s parts. It shows the groups of the part in view, each with a header where it has the room and its tiles inside; a row with no children is a tile of its own. Other props go to the figure. The props from data to messages are the ones every chart takes, less those for a value axis, an order and a pick: a press zooms instead.
TreemapPath
The way back out, above the plot and under a legend at the top: Kino’s Breadcrumb, with a button for each part above the one in view, the whole first, and the part in view last. It is there before the first zoom too, so zooming never moves the plot, and a long path folds into a menu.
ChartTooltip
What is under the pointer or the focus, in the chart’s own words: on a chart with series, the values of the category or the time. It shows at once and slides from one to the next. Other props go to its popup.
ChartLegend
A toggle for each series that shows and hides it. Pointing at one, or focusing it, brings its series forward. Takes position, top or bottom.
Data attributes
CSS variables
Accessibility
- The tiles are one stop in the tab order: a slider over the tiles in view, biggest group first and biggest tile first in each. The arrow keys step through them, Home and End go to the first and last, and each tile’s name, group, value and share are read as the slider’s value.
- Enter or Space on a tile zooms into its group, and the keys start again from the first tile there; once the tooltip is closed, Escape zooms back out.
TreemapPathis a row of buttons for the same, and each zoom is announced in a status region. - A hidden table holds every tile in view with its group, value and share, and the total, for screen readers and for copying.
- Labels show only where they fit whole, near white or near black for the tile’s colour; a tile too small for one keeps its name and value in the tooltip, the table and the slider.
- Groups are named in the legend, their headers and the tooltip, so none relies on colour alone;
patternsadds a pattern too. Forced colours draw each group in a system colour, with the labels on a box of the page’s colours. - When the system asks for less motion, the tiles land at once, with no move, and only their colours and opacity fade.
- The chart is a
<figure>named bylabel. - Escape closes the tooltip and nothing above the chart.
- The legend’s toggles say whether each series shows. When every series is hidden, a button shows them all again and takes the focus.
For agents
What an agent reads on this example with snapshot(), and the actions it can call with act().
The Agent bridge page sets up snapshot() and act() in your app.