# Trend (Lumen Halo): prompt.md (v2.0.0)

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

One number over time, built around a playhead: scrub the line and the big number rolls to that point; round-number milestones and dated events light up as the playhead passes; the line is lit behind it and dim ahead. The insight says how growth changed after the last event. Metric and period tabs, editable markers, and missing values kept as gaps. 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/trend.tsx`; shared code: `lib/beautiful-ui/lumen/trend-model.ts`, `lib/beautiful-ui/lumen/trend-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: `Trend`, `TrendValue`, `TrendPlot`, `TrendInsight`, `TrendTable`, 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 { Trend, TrendInsight, TrendMilestones, TrendPlot, TrendTable, TrendValue } from "@/components/ui/lumen/trend";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `Trend` | — | Data, metric, period, events and the playhead. |
| `TrendValue` | `trend-value` | The number at the playhead, with the delta and date. |
| `TrendPlot` | `trend-plot` | The line, milestones, events and playhead. |
| `TrendInsight` | — | Growth after the last event, or over the period. |
| `TrendTable` | — | Every point 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/trend.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
- a KPI over time with milestones, growth since a launch, before and after an event, annotate a chart with launches or incidents, weekly active users, hero metric with a scrubbable line, Lumen
- One headline number over time, where people scrub back to earlier values
- Showing a launch or incident on the line, and how growth changed after it

### Not when
- Comparing many series at once: use Line
- Values that cross zero often (rates, changes): milestones read as growth
- Thousands of points: roll them up to days or weeks first

## Mistakes
- Dates must be YYYY-MM-DD, oldest first
- Leave a missing week as null, not 0: zero drops the line and fakes a milestone

## Usage

```tsx
import { Trend, TrendInsight, TrendMilestones, TrendPlot, TrendTable, TrendValue } from "@/components/ui/lumen/trend";

<Trend
  metrics={[{ id: "mrr", label: "MRR", unit: "monthly recurring revenue", noun: "MRR" }]}
  periods={[{ id: "12m", label: "12M" }]}
  series={{ mrr: { "12m": points } }}
  events={[{ date: "2026-04-06", label: "Launch" }]}
  config={{ mrr: { label: "MRR", color: "var(--chart-1)" } }}
>
  <TrendValue />
  <TrendPlot />
  <TrendMilestones />
  <TrendInsight />
  <TrendTable />
</Trend>
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `metrics / periods` | `{ id, label, unit?, noun? }[] / { id, label }[]` | `Active and Paid teams / 30D, 90D, 12M` | The tabs. unit reads under the number ("weekly active teams"); noun in sentences ("Active teams"). |
| `series` | `Record<metricId, Record<periodId, { date, value }[]>>` | `a year of Lumen's numbers` | Points oldest first, dates as YYYY-MM-DD. null is missing: the line breaks there. Weekly points read "Wk of Sep 27", monthly ones "Sep 2026". |
| `metric / period (+ default*, on*Change)` | `string` |  | The shown metric and period (default: the first metric and the last period). |
| `events / defaultEvents / onEventsChange` | `{ id?, date, label }[]` |  | Dated markers. Each one's growth before and after is worked out for the insight. |
| `editable` | `boolean` | `false` | Adds a marker field (at the playhead) and remove buttons on markers; changes go to onEventsChange. |
| `pinnedDate / defaultPinnedDate / onPinnedDateChange` | `string \| null` |  | The parked playhead's date (a deep link); null is now. |
| `config` | `ChartConfig` |  | Colours by metric id (shadcn's shape). |
| `title / eyebrow / labels` | `string / string / Partial<TrendLabels>` |  | The accessible name and table caption, the label above the number, and every sentence for i18n. |
| `formatValue / locale` | `(v) => string / string` |  | The big number and the table (grouped whole numbers by default); ticks and milestones are compact. |
| `motion` | `"full" \| "subtle" \| "off"` | `"full"` | full: the playhead sweeps in on each metric or period; subtle: a shorter sweep; off (and reduced motion): no sweep. |
| `Parts` | `TrendValue · Delta · Plot · Milestones · AddMarker · Insight · Metrics · Periods · Replay · Table · Card` |  | Arrange them inside <Trend>, or use TrendCard; useTrend() reads the state. |

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

## 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 |
|---|---|
| ← / → | Move the playhead one point |
| Page Up / Page Down | Move a week (daily) or four points |
| Home / End / Escape | First point / now / back to now |

## Motion inventory

| Interaction | What moves |
|---|---|
| Enter | The playhead sweeps from the first point to now; milestones and events light as it passes |
| Scrub | The number rolls to the point; the line is lit behind the playhead |
| Metric or period | The sweep runs again |

## Accessibility contract (preserve when editing)
- The plot is a slider: arrows move a point, Page Up and Down a week or a month, Home and End the ends; the value text says the date and value
- Milestone chips are toggle buttons that park the playhead, and each move is announced
- The insight is computed and says slower as plainly as faster
- Every point is in the data table

## Install

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

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.
