Kinetik UI

Treemap

.md

Sizes as nested, near-square tiles; tap a group and the map zooms into it as its parts open out inside.

v1.0.0Live on webreact-native-reanimatedreact-native-worklets
Component preview

Installation

Kinetik CLI
npx kinetik-ui add treemap

The CLI copies the source and installs native dependencies with npx expo install, so versions match your Expo SDK. With shadcn: npx shadcn@latest add https://kinetik-ui.dev/r/treemap.json

Install manually

  1. Install dependencies
    npx expo install react-native-reanimated react-native-worklets
  2. Copy the source files
    • components/kinetik/treemap.tsx
    View source files

Usage

import { Treemap } from '@/components/kinetik/treemap';

<Treemap
  accessibilityLabel="Trip spending"
  rootLabel="All spending"
  data={[
    {
      key: 'stays',
      label: 'Stays',
      children: [
        { key: 'flat', label: 'Lisbon flat', value: 920 },
        { key: 'cabin', label: 'Lake cabin', value: 640 },
      ],
    },
    { key: 'tours', label: 'Tours', value: 380 },
  ]}
  formatValue={(v) => `€${v}`}
/>;

Leaves take a value; groups take children and are sized by their sum. Nesting can go as deep as you like; each level is one tap.

When to use

  • Seeing which parts of a whole are big at a glance: spending, storage, sales by region.
  • Hierarchies people want to explore a level at a time.

When not to use

  • Comparing similar sizes precisely. Areas are hard to compare; use Bar Chart.
  • Many tiny parts. Tiles too small for a label are drawn without one.

Notes

  • Tiles are laid out with the squarified algorithm, so they stay as close to square as the sizes allow. squarify and nodeValue are exported.
  • Tapping a group zooms in: the tapped tile grows to fill the frame while its parts open out inside it. The trail above zooms back out the same way.
  • Tiles are shaded by rank, from solid azure for the biggest to a pale wash for the smallest.
  • With reduced motion levels change in place.

Props

TreemapProps

PropTypeDefaultDescription
datarequiredreadonly TreemapNode[]—
accessibilityLabelrequiredstring—What the map shows, read first.
heightnumber280Height of the map. Defaults to 280.
formatValue(value: number) => string(v) => String(Math.round(v))Formats sizes on tiles. Defaults to whole numbers.
rootLabelstring'All'Names the top level in the trail, e.g. "All spending". Defaults to 'All'.
testIDstring—
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
Plain views laid out with a squarified algorithm in JS; each tile springs four values while zooming. Nothing runs at rest.
Measured

Pixel 9 emulator, API 35, release build · interaction median 0.85× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 145 MB app memory

Real-device measurement pending.

Accessibility

Reduced motion
Levels change in place, without the zoom.
Screen readers
Every tile reads its label, size and share; groups are buttons that say they have parts. The trail above has a Back to button for each level.
Touch target
Tiles are as big as their share; the trail's buttons are 44 pt tall. Keep small slices out of a tap-only flow.

Source files

components/kinetik/treemap.tsx is in the Code tab of the preview above.