Histogram

Shows a distribution in adjacent bins with 1px gaps.

Count

Count
LabelCount
0–14
1–211
2–318
3–49
4–53

Bin

Line length

Adjacent bins, one hairline between. A density field on the 204.

Count

Count
Labellines
0–14
1–211
2–318
3–49
4–53

Use it for

  • The distribution of one variable across ordered bins.
  • Adjacent bins with a 1px seam; the order is the axis.

Not for

  • Unordered categories; use BarChart.
  • Time series; use LineChart.

Three ways in. They share one source, so the pixels match whichever you pick.

1. Import the package

npm install @noorddev/vlak-react

// once, next to your app's root
import "@noorddev/vlak-react/css";

import { Histogram } from "@noorddev/vlak-react";

Precompiled React and one stylesheet. No compiler to configure. Per-component imports work too: @noorddev/vlak-react/components/histogram.

2. Vendor the source

npx @noorddev/vlak-cli add histogram

The StyleX leaf lands in components/vlak/ with its dependencies, for your own compiler to own. See StyleX.

3. Through shadcn

npx shadcn add https://vlak.dev/r/histogram.json

The same registry item, installed by shadcn's CLI.

CSS only

<link rel="stylesheet" href="node_modules/@noorddev/vlak/css/vlak.css" />

No React. Link vlak.css and use the markup and classes below.

import { Histogram } from "@noorddev/vlak-react";

<Histogram
  height={204}
  bins={[
    { label: "0–1", count: 4 },
    { label: "1–2", count: 11 },
    { label: "2–3", count: 18 },
  ]}
  yLabel="Sessions"
/>

Histogram

PropTypeDefaultDescription
binsrequiredHistogramBin[]
heightnumber204
unitstring
yLabelstring
gridbooleantrue
ticksnumber4
valueFormat(n: number) => string
spotstring | boolean
localestringBCP 47 tag for number formatting; undefined is the reader's own.

Also accepts HTMLAttributes<HTMLDivElement>.

KeysDoes
TabFocuses the plot
Arrow right, Arrow leftMoves the cursor across the bins; a status tooltip reads the count
Home, EndFirst or last bin
EscapeClears the cursor
<div class="rs-chart"><svg viewBox="0 0 240 64" width="240" height="64"><rect class="rs-chart-hist" x="8" y="36" width="36" height="20"/><rect class="rs-chart-hist" x="45" y="20" width="36" height="36"/><rect class="rs-chart-hist" x="82" y="8" width="36" height="48"/><rect class="rs-chart-hist" x="119" y="24" width="36" height="32"/></svg></div>
.rs-chart-hist