# Flow Funnel (Lumen Halo): prompt.md (v2.0.0)

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

A conversion funnel as a lit band: one ribbon per source narrows stage by stage while people flow through as dots, and what each step loses spills into a tray under the gap. The headline gives the end-to-end rate and the biggest drop; the line under it names the source that over-performs. Sources toggle, the band scale is said in words, and it stands up on phones. 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/flow-funnel.tsx`; shared code: `lib/beautiful-ui/lumen/flow-funnel-model.ts`, `lib/beautiful-ui/lumen/flow-funnel-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: `FlowFunnel`, `FlowFunnelPlot`, `FlowFunnelHeadline`, `FlowFunnelDetail`, `FlowFunnelTable`, 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 { FlowFunnel, FlowFunnelHeadline, FlowFunnelPlot, FlowFunnelSources, FlowFunnelTable } from "@/components/ui/lumen/flow-funnel";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `FlowFunnel` | — | Data, hidden sources, active stage, scale. |
| `FlowFunnelPlot` | `flow-funnel-plot` | The band, ribbons, flow, stage columns and trays. |
| `FlowFunnelHeadline` | — | End-to-end rate and the biggest drop. |
| `FlowFunnelDetail` | `flow-funnel-detail` | The highlighted stage in words, and the band scale. |
| `FlowFunnelTable` | — | Every count 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/flow-funnel.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
- conversion funnel, signup to paid, drop-off by stage, activation funnel by traffic source, acquisition analytics, Lumen
- How people move through a sequence of steps and where they drop off
- Comparing traffic sources inside the same funnel

### Not when
- Events over time or live sessions: the funnel shows period totals
- Steps that aren't a sequence: use Bar or Cell Bars
- More than about five sources: the ribbons get too thin to read

## Mistakes
- counts are people who reached each stage, not people who left it
- Keep stages in order, top of the funnel first

## Usage

```tsx
import { FlowFunnel, FlowFunnelHeadline, FlowFunnelPlot, FlowFunnelSources, FlowFunnelTable } from "@/components/ui/lumen/flow-funnel";

<FlowFunnel
  stages={["Visited", "Signed up", "Onboarded", "Paid"]}
  sources={[{ id: "search", label: "Search" }, { id: "social", label: "Social" }]}
  counts={[[42000, 6100, 3900, 610], [18000, 2100, 1100, 150]]}
  config={{ search: { label: "Search", color: "var(--chart-1)" }, social: { label: "Social", color: "var(--chart-2)" } }}
>
  <FlowFunnelHeadline />
  <FlowFunnelSources />
  <FlowFunnelPlot />
  <FlowFunnelTable />
</FlowFunnel>
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `stages / sources / counts` | `string[] / { id, label }[] / (number \| null)[][]` | `the sample funnel` | counts[source][stage]: people from each source who reached each stage. A count above the previous stage is capped (and said); null is missing and marks the stage partial. |
| `hiddenSources / defaultHiddenSources / onHiddenSourcesChange` | `string[]` |  | Hidden source ids. At least one source always stays visible. |
| `activeStage / defaultActiveStage / onActiveStageChange` | `number \| null` |  | The highlighted stage's index: its numbers show in the detail line and the rest dim. |
| `scale / defaultScale / onScaleChange` | `"sqrt" \| "linear"` | `"sqrt"` | Band thickness ∝ √people (keeps a 2% last stage visible) or ∝ people. Always labelled. |
| `config` | `ChartConfig` |  | Colours by source id (shadcn's shape). |
| `title / eyebrow / unit` | `string` | `"Flow funnel" / — / "visitors"` | The accessible name and table caption, the label above the headline, and what the counts count. |
| `labels` | `Partial<FlowFunnelLabels>` |  | Every sentence and word, for i18n; interpolated entries are functions of already-formatted values. |
| `formatValue / formatPercent / locale` | `(v) => string / (ratio, digits) => string / string` |  | Counts and ratios; digits is the designed precision for that spot (0, 1 or 2). |
| `motion` | `"full" \| "subtle" \| "off"` | `"full"` | full: dots flow; subtle: slower; off (and reduced motion): still. |
| `Parts` | `FlowFunnelPlot · Headline · Insight · Sources · Scale · Detail · Table · Card` |  | Arrange them inside <FlowFunnel>, or use FlowFunnelCard; useFlowFunnel() reads the state. |

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

## 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 between stages |
| Home / End | First or last stage |
| Escape | Clear the highlighted stage |

## Motion inventory

| Interaction | What moves |
|---|---|
| Enter | The band draws in from the top of the funnel |
| Flow | People flow through each ribbon as dots (slower when subtle, still when off) |
| Stage | The other stages and trays dim |

## Accessibility contract (preserve when editing)
- The plot is one tab stop: arrows walk the stages and each is announced with its count, its rate against the previous and the first stage, and who didn't reach the next
- Source chips are toggle buttons with their share of the first stage; toggles are announced
- The headline and insight are computed and stay true for one source, zeros, capped and missing counts
- Every count is in the data table

## Install

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

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.
