# Market Breadth (Lumen Halo): prompt.md (v1.0.0)

- id: `lumen-market-breadth` · version 1.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-market-breadth`
- npm dependencies: none
- 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-market-breadth
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

How broad is the growth? Every market that beat its weekly target drops in as a square, so a year of breadth reads in one look: tall columns, dips around an event, a traced market's streak. In parts, with the finished card as the recipe.

## 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/market-breadth.tsx`; shared code: `lib/beautiful-ui/lumen/market-breadth-model.ts`, `lib/beautiful-ui/lumen/market-breadth-sample.ts`, `lib/beautiful-ui/lumen/sound.ts`.
- 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: `MarketBreadth`, `MarketBreadthPlot`, `MarketBreadthReadout`, `MarketBreadthStats`, `MarketBreadthModes`, `MarketBreadthLegend`, `MarketBreadthReplay / MarketBreadthTracing`, `MarketBreadthTable`, `MarketBreadthCard`, `useMarketBreadth`, 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 { MarketBreadth, MarketBreadthLegend, MarketBreadthModes, MarketBreadthPlot, MarketBreadthReadout, MarketBreadthTable } from "@/components/ui/lumen/market-breadth";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `MarketBreadth` | — | Holds the data, mode, trace and hover; every part reads it. |
| `MarketBreadthPlot` | `market-breadth-plot` | The canvas of squares, axis, months, event band and tooltip. |
| `MarketBreadthReadout` | `market-breadth-readout` | The latest (or hovered) week's count, rolling. |
| `MarketBreadthStats` | `market-breadth-stats` | Hit rate, best week, longest run, most consistent. |
| `MarketBreadthModes` | — | All beats, strong beats, runs. |
| `MarketBreadthLegend` | — | The three bins. |
| `MarketBreadthReplay / MarketBreadthTracing` | — | Drop again; the traced market's pill. |
| `MarketBreadthTable` | — | The year as a table, on demand. |
| `MarketBreadthCard` | — | The recipe: every part on the sample data. |
| `useMarketBreadth` | — | The state, for parts of your own. |

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/market-breadth.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
- how many markets, regions, teams or stores hit their weekly target, breadth of performance over a year, streaks, target tracking, story chart, Lumen
- Breadth: how many of a fixed set (markets, regions, teams, stores) beat a weekly target, week by week
- Streaks and dips around an event (a launch, a migration), annotated under the axis
- A board or report that must say "how many are on track" before "by how much"

### Not when
- A single metric over time: use a trend line
- More than about 40 series: the columns get too tall to read

## Mistakes
- value is % over target, not the raw revenue: compute it per market first
- Keep market names stable: pinned and the table use them
- Don't pass the sample's firstWeek or annotation with your own data

## Usage

```tsx
import { MarketBreadth, MarketBreadthLegend, MarketBreadthModes, MarketBreadthPlot, MarketBreadthReadout, MarketBreadthTable } from "@/components/ui/lumen/market-breadth";

<MarketBreadth data={weeklyResults} firstWeek="2026-01-05" title="Regions on target">
  <MarketBreadthReadout />
  <MarketBreadthPlot />
  <MarketBreadthModes />
  <MarketBreadthLegend />
  <MarketBreadthTable />
</MarketBreadth>

// Or the finished card, on the sample data (copy its source to rearrange):
<MarketBreadthCard />
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `MarketBreadth data` | `{ week: number; market: string; value: number }[]` |  | value is % over the market's target that week (negative: a miss). Missing weeks count as a miss and break a streak. |
| `markets / weeks / firstWeek` | `string[] / number / ISO date` |  | Plot order (default: order of appearance), columns (default: from the data) and week 0's date for labels (without it weeks are numbered). |
| `strongAt / hotAt / runWeeks` | `number` | `0.6 / 1.5 / 4` | The bins' edges in % and the shortest streak for the runs mode. |
| `mode / defaultMode / onModeChange` | `"all" \| "strong" \| "streak"` | `"all"` | Every beat, beats by strongAt% or more, or runs of runWeeks+. |
| `pinned / defaultPinned / onPinnedChange` | `string \| null` |  | The traced market, by name. |
| `annotation` | `{ label, fromWeek, toWeek } \| null` |  | An event band under the axis. |
| `config` | `ChartConfig` |  | Colours by key: low, mid, high (the bins) and trace. |
| `labels` | `Partial<MarketBreadthLabels>` |  | Every word, as plain strings with {placeholders}. |
| `motion / speed / bounce` | `"full" \| "subtle" \| "off" / number / number` | `"full" / 1 / 0.3` | Off and reduced motion snap squares into place. |
| `MarketBreadthPlot height` | `number \| string` |  | Most the square grid may take; default from the width, up to 456px. |

Full docs: https://beautiful-ui.dev/components/lumen-market-breadth

## 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 |
|---|---|
| ← → | Previous or next week |
| ↑ ↓ | Up or down the week's squares |
| Home / End | First or last week |
| Enter / Space | Trace the focused square's market |
| Escape | Stop tracing, then leave the square |

## Motion inventory

| Interaction | What moves |
|---|---|
| First view | A scan line sweeps the year and squares drop into their weeks with gravity and a small bounce |
| Mode change | Filtered squares flash and pop; the rest settle into their new slots |
| Drop again | Replays the intro |
| Reduced motion or off | Squares appear in place |

## Accessibility contract (preserve when editing)
- The plot is one tab stop: arrows move between weeks and squares, Enter traces a market, Escape stops
- Each focused square is announced (market, value, week, run); the canvas carries a one-line summary
- The whole year is a table behind "View as table" (1,040 cells is more than a screen reader wants at once)
- Colour is never alone: the tooltip and the table say the value; the legend names the bins

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/lumen-market-breadth
```

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.

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.
