# Bullet Chart (Lumen Halo): prompt.md (v1.0.0)

- id: `lumen-bullet-chart` · version 1.0.0 · component · pro (Pro)
- category: Charts
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/lumen-bullet-chart`
- npm dependencies: recharts@^3
- registry dependencies: utils, @beautiful-ui/lumen-chart, @beautiful-ui/lumen-stat, https://beautiful-ui.dev/r/lumen-foundation.json
- docs: https://beautiful-ui.dev/components/lumen-bullet-chart
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

Actual against target, one row per measure, over bands that say what good looks like. Each row has its own scale, so revenue, NPS and response time can share one card; the share of target is written at the end of every row.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: `recharts@^3`.
- Files: `components/ui/lumen/charts/bullet-chart.tsx`, `components/ui/lumen/charts/chart-frame.tsx`, `components/ui/lumen/charts/cartesian.tsx`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `lumen-chart`, `lumen-stat`, `lumen-foundation`.
- Builds: one set of files for both, but its dependencies come in Base UI and Radix builds. Install the one that matches the project (see Install): a free item's bare URL installs the Base UI build of it and its dependencies.
- Exports to keep: `BulletChart`, and every exported type.
- CSS: the install merges this item's rules (the registry `css` field) into your global stylesheet, in `@layer components`, and adds the lumen foundation (tokens, keyframes, motion levels) once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Tokens: retheme with the `--lumen-*` custom properties (`--lumen-accent`, `--lumen-accent-foreground`, `--lumen-accent-text`, `--lumen-bad`, `--lumen-bad-text`, `--lumen-chart-accent`, `--lumen-chart-accent-foreground`, `--lumen-chart-accent-text`, `--lumen-focus`, `--lumen-good`, `--lumen-good-text`, `--lumen-hairline`, `--lumen-ink`, `--lumen-muted-ink`, `--lumen-series-1`, `--lumen-series-2`, `--lumen-series-3`, `--lumen-series-4`, `--lumen-series-5`, `--lumen-series-6`, `--lumen-warn`, `--lumen-warn-text`); this item's CSS also reads `--lumen-font-mono`, `--lumen-font-sans`, `--lumen-radius-k`. Never add Tailwind colour classes inside the component.

```tsx
import { BulletChart } from "@/components/ui/lumen/charts/bullet-chart";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `BulletChart` | — | The rows, bands, bars, targets, states, summary and table. |

## Sound
- Keep every `data-slot` and `data-sound` attribute: the sound layer reads them.
- Installing this item adds no audio. Nothing plays until the app mounts `GlassSoundProvider` once (install: `npx shadcn@latest add https://beautiful-ui.dev/r/glass-sound.json`, import from `@/components/beautiful-ui/glass-sound`); `GlassSoundToggle` is its mute control. Without a provider the audio engine never loads.

## Match the original
- Read `components/ui/lumen/charts/bullet-chart.tsx`, `components/ui/lumen/charts/chart-frame.tsx`, `components/ui/lumen/charts/cartesian.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when
- bullet chart, actual vs target, KPI vs goal, budget vs actual, quota attainment, performance bands, scorecard
- Several KPIs against their own targets in one compact card
- When 'how good is this' needs bands (poor, fair, good), not just a target

### Not when
- One headline number: use Stat
- A value changing over time: use a Line or Area Chart

## Mistakes
- Keep data and config stable (outside the component, or memoised)
- Each row has its own scale: compare rows by share of target, not bar length
- For less-is-better measures set direction="down", or 'met' reads backwards

## Usage

```tsx
"use client";
import { BulletChart } from "@/components/ui/lumen/charts/bullet-chart";

const kpis = [
  { kpi: "revenue", actual: 412, target: 450, bands: [300, 400, 500] },
  { kpi: "nps", actual: 48, target: 40, bands: [20, 35, 60] },
  { kpi: "activation", actual: 61, target: 70, bands: [40, 60, 100] },
];

const config = {
  revenue: { label: "Revenue ($k)", color: "var(--chart-1)" },
  nps: { label: "NPS", color: "var(--chart-2)" },
  activation: { label: "Activation (%)", color: "var(--chart-3)" },
};

export function QuarterScorecard() {
  return <BulletChart data={kpis} name="kpi" value="actual" target="target" bands="bands" config={config} label="Quarter scorecard" />;
}
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `data / name / value / target` | `Row[] / field / field / field` |  | One row per measure: its name, the actual value and (optionally) its target. |
| `bands` | `field \| number[]` |  | Upper edges of the bands, low to high: a field holding an array per row, or one array for every row. |
| `bandLabels` | `string[]` | `["Poor", "Fair", "Good"]` | Band names, low to high, used in the table and the words. |
| `max` | `field \| number` |  | Each row's scale end. Default: the largest band, value or target, rounded up. |
| `direction` | `"up" \| "down"` | `"up"` | down: less is better (costs, latency); the bands and 'met' read the other way. |
| `config` | `ChartConfig` |  | Colour and label per row name. Unlisted rows take the series colours in order. |
| `valueFormat` | `StatFormat \| (n) => string` |  | Numbers in the rows, table and summary. |
| `active / onActiveChange / onSelect` | `string \| null / (name) => void / (name) => void` |  | The focused row, controlled; and a row was clicked or Enter pressed. |
| `labels` | `{ ofTarget?, noData? }` |  | Words for i18n. |
| `rowHeight` | `number` | `44` | Height of one row in px. |
| `motion` | `"full" \| "subtle" \| "off"` | `"full"` | Bars grow in, row by row; reduced motion always wins. |
| `loading / error / emptyText / label` | `boolean / string / string / string` |  | States in words with the height held, and the chart's accessible name. |

Full docs: https://beautiful-ui.dev/components/lumen-bullet-chart

## Customising
- Motion: `motion="full"` (default) | `"subtle"` | `"off"`. prefers-reduced-motion is always respected.
- Colours: set the `--lumen-*` tokens on `:root`, or on a container with the `lumen-scope` class to retheme one area. Add the `lumen-inherit` class to follow your shadcn palette instead (`--chart-N`, `--destructive`).
- Dark mode follows the `.dark` class on an ancestor (the shadcn and next-themes convention).
- Update later by re-running the install with `--overwrite` (review the diff if you edited it). Changelog: https://beautiful-ui.dev/r/changelog.json

## Keyboard

| Keys | Action |
|---|---|
| Tab | Focus the rows |
| ↑ / ↓ / ← / → | Move between rows; the live region says the row |
| Home / End | First or last row |
| Enter / Space | Select the focused row (onSelect) |
| Escape | Clear the focus |

## Performance

- Plain HTML rows (a few spans each), no chart library work at runtime; fine for dozens of rows

## Responsive

- Under 420px of card width each row stacks: name and value on one line, the bar below at full width

## Motion inventory

| Interaction | What moves |
|---|---|
| Draw | Bars grow from zero, one row after another (motion="subtle" is quicker) |
| Change | Bars ease to their new length |
| Focus | The focused row lifts and the others dim |

## Accessibility contract (preserve when editing)
- A labelled figure; the rows are one tab stop (role application) and arrow keys move between them, said through a polite live region
- Every row writes its value and share of target, so colour and position are never the only cue; met targets also read in the good colour
- A one-sentence summary and the full table (with each row's band) for screen readers
- Negative values are refused in words; missing values are named

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/lumen-bullet-chart
```

Pro item: needs the `@beautiful-ui-pro` registry in `components.json` and `BEAUTIFUL_UI_TOKEN` in `.env.local` (https://beautiful-ui.dev/account). Setup: https://beautiful-ui.dev/docs/pro. Your components.json `style` picks the build: radix-*, new-york and default get Radix, base-* gets Base UI.

## Credits
- Built on shadcn/ui charts conventions (https://ui.shadcn.com/charts)

The lumen foundation (the tokens listed above, keyframes and motion levels) installs once with the first component; its CSS is public at https://beautiful-ui.dev/r/lumen-foundation.json.
