Bullet chart
Actual against target for a few measures at once: a bar for the value, a tick for the target, and shaded ranges that say whether the value is poor, fair or good. It replaces a row of gauges in a fraction of the room. For one reading on a fixed scale, use the gauge.
Install
npx shadcn@latest add @thrum-pro/bullet-chartThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Data shape
type BulletChartMeasure = {
name: string;
value: number | null; // the bar
target?: number | null; // the tick
ranges: number[]; // 2 or 3 upper ends, low to high
format?: Intl.NumberFormatOptions;
};[
{ name: "Revenue", value: 268000, target: 250000, ranges: [150000, 225000, 300000] },
{ name: "Profit", value: 22.5, target: 26, ranges: [20, 25, 30],
format: { style: "percent" } },
]Props
| Prop | Type | Default | Description |
|---|---|---|---|
measures | readonly BulletChartMeasure[] | Required | One row per measure, top to bottom. Each row has its own scale from zero (or its lowest value) to the end of its last range, widened to a round number when the value or the target goes past it. |
label | string | Required | What the chart shows as a whole. Read by screen readers and used as the table caption. |
rangeNames | readonly string[] | Default ["Poor", "Fair", "Good"] | Names of the qualitative ranges, lowest first, read in the readout and the table. With two ranges the default is Poor and Good. |
color | string | Default var(--foreground) | Any CSS colour for the bar and the target tick. The default keeps 3:1 against every range tint in both themes. |
format | Intl.NumberFormatOptions | Default compact | How values are written on the axis, in the readout and in the data table. A measure's own format wins. |
locale | string | Default "en-US" | Locale for number formatting. Fixed by default so the server and the browser print the same text. |
axis | boolean | Default true | Show a scale with value labels under each row, two to six labels depending on the width. |
onActiveChange | (index: number | null) => void | – | Called with the index of the row under the cursor, or null when the cursor leaves. |
sound | boolean | Default true | Play a tick as the cursor moves between rows, if the visitor has sound on. |
emptyLabel | string | Default "No data" | Text shown when there are no measures. |
className | string | – | Sets the width; the default is full width. The height follows the rows: 52 pixels each with the axis, 34 without, less 10 for the last. |
Motion and sound
Motion
- First draw: each bar grows from zero in 250 ms, rows starting 40 ms apart.
- New data: bars and target ticks move to their new values in 400 ms with no overshoot.
- The band behind the active row follows the pointer on a stiff spring.
- Reduced motion: the chart appears complete, and changes and the cursor move instantly.
Sound
- A soft tick each time the cursor lands on a different row, at most one every 40 ms.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The chart is one tab stop. It is exposed as a slider whose value text is the row under the cursor, for example “Revenue: $268K, target $250K, Good”.
- A visually hidden table carries every measure with its actual value, target and range.
- The ranges are tints of one neutral, told apart by lightness, and the range is named in words in the readout and the table. The bar and the tick differ by shape, and a 2 pixel ring of background keeps the tick apart from the bar.
- Names longer than the label column (at most 40% of the width) end in an ellipsis; the readout and the table carry them in full.
- Each whole row, label included, is the pointer target.
| Keys | Action |
|---|---|
| Tab | Focus the chart. The cursor goes to the last row. |
| ↓ ↑ | Move the cursor one row down or up. |
| → ← | Also move one row down or up. |
| Home / End | Jump to the first or last row. |
| Esc | Hide the cursor. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/bullet-chart.tsx- Packages
motion- Brings along
- Chart foundationsMotion tokensSound engine
Changelog
- 1.0.0 · 2026-12-03First release.