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

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

Compare categories grouped, stacked or as percent, standing or lying down. Bars have a lit edge at their value end (the bottom for negatives); highlight the max, min or any bar and the rest dim; values at the ends; legend toggles; a table for screen readers.

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

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `BarChart` | — | 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/bar-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
- bar chart, column chart, stacked bar, horizontal bar, grouped bar, compare categories, best week, Recharts, Lumen
- Comparing amounts across categories or periods

### Not when
- A continuous trend over many points: use Line
- Parts of one whole: use Donut

## 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 { BarChart } from "@/components/ui/lumen/charts/bar-chart";

<BarChart data={weeks} x="week" config={{ revenue: { label: "Revenue", color: "var(--chart-1)" } }} highlight="max" valueFormat={{ style: "currency" }} />
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `stack` | `"grouped" \| "stacked" \| "percent"` | `"grouped"` | Side by side, a total, or shares of each total (values of zero or more). |
| `orientation` | `"vertical" \| "horizontal"` | `"vertical"` | Horizontal reads long category names better. |
| `highlight` | `"max" \| "min" \| number` |  | Light one bar and dim the rest (single series). |
| `showValues / radius` | `boolean / number` | `false / 4` | Values at the bar ends; corner radius. |
| `onSelect` | `(row, index) => void` |  | A bar was clicked. |
| `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. |
| `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-bar-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 | Bars grow from the baseline; the highlighted bar's edge glows |

## 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-bar-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.
