Power-User Systems

Treemap

A treemap you can walk into. Every box is a share of the whole, and a box with children is a frame with its children packed inside. Click a frame and it grows to fill the view. The cells that stay on screen slide to their new place, the new ones arrive from where they would have been, and a path at the top takes you back out. Arrow keys move between cells by where they are on screen. With live on, the values wander and the map keeps reflowing.

Install

# Treemap needs no npm packages

Then copy 3 files into your project:

  • components/registry/treemap/treemap.tsx
  • components/registry/treemap/treemap-layout.ts
  • hooks/use-animation-loop.ts

Props

PropTypeDefaultDescription
gapnumber3Space between cells.
depthnumber2How many levels are drawn below the one you are in. At 1 each division is a single box.
livebooleantrueThe values wander and the map is laid out again as they change.
speednumber1How often the live values change.
labelsbooleantruePrint a name and a value in every cell that has room.
colorBy"branch" | "size" | "depth""branch"What a cell's shade means: which branch it is in, how big it is, or how deep it sits.
durationnumber520How long a zoom or a reflow takes. 0 cuts.
radiusnumber4Corner radius of a cell.
accentColorstring (hex)"#a855f7"The strong end of the color ramp.
baseColorstring (hex)"#16121f"The weak end of the ramp, and the ground under the cells.

What It Demonstrates

Layout animation
When an element's size or position changes, it animates to the new spot instead of snapping.
Continuity transition
A change that keeps the user oriented by visually connecting before and after. For example, making the same rectangle bigger and smaller.
Spatial consistency
Animating so an element keeps its identity and position across states, so users never lose track of where things went.
Hover effect
Visual change when the cursor moves over an element.
Idle animation
Subtle motion that plays while an element is just sitting there, waiting to be interacted with.

Related Components

Appears In