npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kevinwang15/treebox

v0.3.0

Published

Treebox is an interactive TreeMap visualization

Readme

treebox

Treebox is an interactive TreeMap visualization.

Try the live demo

  • weight-aware multi-level hierarchical treemap layout
  • click on a block to zoom in / Esc or scroll down to zoom out
  • Ctrl-click (Cmd-click on macOS) or Shift+Enter on a block fires an open event instead of zooming
  • drag to zoom into a selected area; scroll up to retrace a zoom-out
  • keyboard-focusable canvas with arrow, Enter, Space, and Esc controls
  • pointer and touch support, with automatic container resize reflow
  • smooth transition
  • uses canvas & requestAnimationFrame for performance
  • customize text / color / weight, and style gaps, corners, fonts, and labels
  • wraps long and multiline labels within their available bounds
  • fires events (so you can implement tooltip, etc.)
  • no runtime dependencies (about 10kb gzipped)
  • MIT license

Demo

Explore the interactive example at kevinwang15.github.io/treebox.

Run the demo locally

git clone https://github.com/KevinWang15/treebox
cd treebox
npm install
npm start

Run the repeatable layout, painting, label, and hit-testing benchmarks with npm run benchmark.

Install

npm i @kevinwang15/treebox
export function genData(layers = 4) {
  const result = [];

  for (let i = 0; i < 7; i++) {
    const children = layers - 1 > 0 ? genData(layers - 1) : null;
    result.push({
      text: `${layers}-${i}`,
      color: "red",
      children,
      weight: children ? null : Math.floor(10 * (1 + 2 * Math.random())),
    });
  }

  return result;
}

color accepts a CSS color string or a callback receiving { ctx, hovering, item, bounds } when the color needs to be dynamic.

import TreeBox from "@kevinwang15/treebox";

const domElement = document.querySelector("#treemap");
const treebox = new TreeBox({
  pixelRatio: Math.min(window.devicePixelRatio || 1, 2),
  data: genData(),
  domElement,
  eventHandler: (type, payload) => console.log(type, payload),
});

// Hover events receive the active item, then null when hover/focus leaves.
// Zoom events include { node, direction, depth, canZoomOut }; direction is
// "in", "out", "redo", "select" (an area selection), or "to" (zoomTo).
// Open events receive the block that was Ctrl/Cmd-clicked or Shift+Entered.

// Zoom to any item in `data`, or back to the top with null, for example when
// the page's own navigation changes. It animates through the levels between
// (pass { animate: false } to jump), replaces the zoom history with the path to
// the item, and fires a zoom event with direction "to". zoomOut() steps back
// up one level, like Escape.
treebox.zoomTo(data[0].children[2]);

// Keep the backing store sharp after browser zoom or a display change.
treebox.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));

function destroyTreebox() {
  treebox.destroy();
}

// Call destroyTreebox() when the surrounding view is removed.

Styling

Pass style to the constructor, or call setStyle later (for example when the page switches theme). Every option is optional, and the defaults keep the original look. Sizes are CSS pixels.

const treebox = new TreeBox({
  data,
  domElement,
  style: {
    gap: 3,
    cornerRadius: 6,
    fontFamily: "Inter, sans-serif",
    fontWeight: 600,
    textColor: "#ffffff",
    textStroke: null,
    textAlign: "start",
    textPadding: 10,
  },
});

// Merge new values into the current style, or pass null to reset.
treebox.setStyle({ textColor: "#111827" });

| Option | Default | | | -------------- | ----------------------------------- | ----------------------------------------------------------------------------- | | gap | 2 | Space between adjacent blocks. | | cornerRadius | 0 | Block corner radius, capped at half the block. | | fontFamily | "sans-serif" | Label font family. | | fontWeight | "normal" | Label font weight: a keyword or 1 to 1000. | | minFontSize | 6 | Blocks too small for this label size show none. | | maxFontSize | 160 | Largest label size. Labels otherwise scale with their block. | | textColor | "white" | A CSS color, or a callback receiving { ctx, hovering, item, bounds }. | | textStroke | "rgba(9, 14, 25, 0.84)" | Outline behind label text, or null for none. | | textAlign | "center" | "center", or "start" to anchor labels to the top-left (top-right in RTL). | | textPadding | 0 | Space between a block's edge and its label. | | hoverOpacity | 0.6 | Opacity of a hovered or focused block, so the next level shows through. | | hoverFilter | "brightness(110%) saturate(120%)" | Canvas filter for a hovered block, or "none". |

Unknown options and invalid values throw a TypeError, so typos fail loudly.

CommonJS consumers can use const TreeBox = require("@kevinwang15/treebox"). Loading treebox.js directly in a browser exposes the same constructor as window.treebox. Legacy consumers can continue reading the constructor from .default.

Roadmap

  • more customization options
  • customizable transition timing