# Cell Bars (Lumen Halo): prompt.md (v2.0.0)

- id: `lumen-cell-bars` · version 2.0.0 · component · pro (in Lumen Story Charts, $39, or All-Access)
- 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-cell-bars`
- npm dependencies: none
- registry dependencies: utils, @beautiful-ui/lumen-chart, https://beautiful-ui.dev/r/lumen-foundation.json
- docs: https://beautiful-ui.dev/components/lumen-cell-bars
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

Bars built from rounded cells that pour in from zero. The headline names the leader; a level line and dashed ghost cells show every bar's gap to it; ticks mark the previous period; an oversized bar compresses behind a break until you ask for true scale. Stacked or grouped, sorted, standing or lying down, signed changes too. In parts.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: none beyond React.
- Files: `components/ui/lumen/cell-bars.tsx`; shared code: `lib/beautiful-ui/lumen/cell-bars-model.ts`, `lib/beautiful-ui/lumen/cell-bars-sample.ts`, `lib/beautiful-ui/lumen/sound.ts`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `lumen-chart`, `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: `CellBars`, `CellBarsPlot`, `CellBarsHeadline`, `CellBarsNote`, `CellBarsTable`, 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-text`, `--lumen-bad`, `--lumen-bad-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 { CellBars, CellBarsHeadline, CellBarsPlot, CellBarsNote, CellBarsTable } from "@/components/ui/lumen/cell-bars";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `CellBars` | — | Data, datasets, level, layout, sort, orientation, true scale. |
| `CellBarsPlot` | `cell-bars-plot` | The cells, level, gaps, ticks and break. |
| `CellBarsHeadline` | — | The computed headline. |
| `CellBarsNote` | `cell-bars-note` | What the level is, how to change it, and true scale. |
| `CellBarsTable` | — | Every value for screen readers. |

Style a part with `[data-slot="<slot>"]` selectors or its `className`; keep the attributes when editing.

## 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/cell-bars.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
- bar chart with benchmark, compare against leader, gap to target, cell bar chart, stacked bars, previous period comparison, net change bars, Lumen
- Comparing categories against a leader or a chosen benchmark, with how far each falls short
- This period against the last, per category

### Not when
- A trend over many periods: use Line
- Exact values in a dense grid: use a table or Heatmap

## Mistakes
- Use Line for many periods: cells suit a handful of categories
- Set signed for net changes, or negative values are treated as missing height

## Usage

```tsx
import { CellBars, CellBarsHeadline, CellBarsPlot, CellBarsNote, CellBarsTable } from "@/components/ui/lumen/cell-bars";

<CellBars categories={features} series={[{ id: "returning", label: "Returning" }, { id: "new", label: "New" }]} prevLabel="Q2">
  <CellBarsHeadline />
  <CellBarsPlot />
  <CellBarsNote />
  <CellBarsTable />
</CellBars>
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `categories / series` | `{ id?, name, values, prev? }[] / { id, label }[]` |  | One set of bars: values per series (1–6), and optional previous-period values for the ticks. |
| `datasets / dataset / defaultDataset / onDatasetChange` | `{ id, label, categories, series?, signed?, prevLabel?, eyebrow? }[]` |  | Several sets to switch between (tabs). |
| `signed` | `boolean` |  | Values are signed changes: bars go below zero, gaps read as differences. |
| `config` | `ChartConfig` |  | Colours by series id (shadcn's shape). |
| `layout / sort / orientation / showPrev` | `controlled or default*` |  | Stacked or grouped; by value or given order; vertical or horizontal (always horizontal below 520px of plot); previous-period ticks. |
| `level / defaultLevel / onLevelChange` | `string \| null` |  | The benchmark bar's id; null is the leader. |
| `trueScale / defaultTrueScale / onTrueScaleChange` | `boolean` |  | True scale for a bar over 2.6× the next (otherwise compressed behind a break). |
| `formatValue / locale` | `(v) => string / string` |  | Values (labels, tooltip, table); compact by default. |
| `onCategoryClick` | `(id) => void` |  | A bar was activated (Enter or click), after it became the level. |
| `title / eyebrow / prevLabel / motion` | `…` |  | Names, the previous period's name, and motion (reduced motion wins). |
| `Parts` | `CellBarsPlot · Headline · Layout · Sort · Orientation · Prev · Datasets · Legend · Note · Table · Card` |  | Arrange them inside <CellBars>, or use CellBarsCard; useCellBars() reads the state. |

Full docs: https://beautiful-ui.dev/components/lumen-cell-bars

## Customising
- 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 |
|---|---|
| ← / → | Move between bars |
| Enter / Space | Set the focused bar as the level |
| Escape | Level back to the leader |

## Motion inventory

| Interaction | What moves |
|---|---|
| Enter | Cells pour in from zero, bar by bar |
| Level | The level line moves; ghost cells show each gap |
| Outlier | A bar over 2.6× the next breaks; True scale draws it in full |

## Accessibility contract (preserve when editing)
- The plot is one tab stop: arrows walk the bars and each is announced with its value and gap to the level
- Enter sets the focused bar as the level, Escape resets to the leader; each change is announced
- The headline is computed and stays true for ties, a single bar, all zeros and signed changes
- Every value (and the previous period) is in the data table

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/lumen-cell-bars
```

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 chart 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.
