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

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

Volume over time, overlaid, stacked into a total or as the mix in percent: lit top edges over bodies that fade to nothing, legend toggles, Lumen's tooltip and a table for screen readers. Percent stacking refuses negative values in words.

## 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/area-chart.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: `AreaChart`, 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 { AreaChart } from "@/components/ui/lumen/charts/area-chart";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `AreaChart` | — | The plot, legend, tooltip, references, 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/area-chart.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
- area chart, stacked area, percent area, mix over time, composition over time, Recharts, Lumen
- How a total is made up over time, or how the mix shifts

### Not when
- Exact values to compare: use Line or Bar
- Series with negative values stacked: use Bar (stacked) or Line

## Mistakes
- Keep config and data stable (outside the component, or memoised)
- Give series colours through config (var(--chart-N) or theme), not inline

## Usage

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

<AreaChart data={weeks} x="week" config={config} stack="percent" />
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `stack` | `"none" \| "stacked" \| "percent"` | `"none"` | Overlaid, a total, or each series' share of the total (values of zero or more). |
| `fill` | `"gradient" \| "solid" \| "none"` | `"gradient"` | The body under each edge. |
| `curve` | `"monotone" \| "linear" \| "step" \| "natural"` | `"monotone"` | The edge's shape. |
| `data / x` | `Row[] / keyof Row` |  | Rows as they are (your own Recharts children see every field) and the field for the x axis. |
| `config` | `ChartConfig` |  | shadcn's shape: one entry per series with label and color or theme { light, dark }. |
| `series` | `string[]` |  | Which config keys to draw, in order. Default: all. |
| `valueFormat / formats` | `StatFormat \| (n) => string` |  | valueFormat formats the value axis, tooltip, table and summary (Intl). formats sets a different one per series for the tooltip, table and summary; the axis keeps valueFormat (Composed: rightFormat for the right axis). In percent stacking the chart plots shares, so extra Recharts children see shares, not raw values. |
| `xFormat / xLabel` | `(v) => string / string` |  | How x values read, and the x axis's name in the table. |
| `height` | `number` | `280` | Plot height in px; the width follows the container. |
| `grid / axes` | `"horizontal" \| "vertical" \| "both" \| "none" / { x?, y? }` | `"horizontal"` | Grid lines and which axes show. |
| `yDomain` | `"zero" \| "fit" \| [number, number]` | `"zero"` | The value axis's range: from zero, fitted to the data (rates and slow-moving levels, where zero hides every change), or fixed. |
| `legend` | `"toggle" \| "static" \| "none"` | `"toggle" with 2+ series` | Toggle buttons hide and show series; the last visible one can't be hidden. |
| `tooltip` | `boolean` | `true` | Lumen's glass tooltip with each series' value. |
| `references` | `{ y?, x?, label, tone? }[]` |  | Labelled reference lines: targets, limits, launches. |
| `motion` | `"full" \| "subtle" \| "off"` | `"full"` | Reduced motion always wins. |
| `loading / error / emptyText` | `boolean / string / string` |  | States in words, with the plot's height held. |
| `label` | `string` |  | Names the chart for assistive tech and its table. |
| `children` | `Recharts elements` |  | Your own lines, reference areas or labels, drawn with the rest. |

Full docs: https://beautiful-ui.dev/components/lumen-area-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 chart, then the legend |
| ← / → | Move between points; the tooltip follows |
| Enter / Space | Toggle a focused legend entry |

## Motion inventory

| Interaction | What moves |
|---|---|
| Draw | Areas rise from the baseline |

## Accessibility contract (preserve when editing)
- A labelled figure; Recharts' accessibility layer lets arrow keys walk the points with the tooltip following
- A one-sentence summary (ranges, highs and lows per series) and the full data table for screen readers
- Legend toggles are buttons with a pressed state; the last visible series can't be hidden
- Errors and empty data are said in words

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/lumen-area-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
- Recharts (https://recharts.org)
- shadcn/ui charts (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.
