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

- id: `lumen-filter-bar` · version 1.0.0 · component · pro (All-Access)
- category: Data
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/lumen-filter-bar`
- npm dependencies: react-day-picker@^10
- registry dependencies: utils, @beautiful-ui/lumen-button, @beautiful-ui-pro/lumen-calendar, @beautiful-ui/lumen-checkbox, @beautiful-ui/lumen-input, @beautiful-ui-pro/lumen-popover, @beautiful-ui/lumen-radio-group, @beautiful-ui-pro/lumen-sheet, @beautiful-ui-pro/lumen-slider, https://beautiful-ui.dev/r/lumen-foundation.json
- docs: https://beautiful-ui.dev/components/lumen-filter-bar
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

Search and one pill per filter: dashed until set, then solid with its value and a clear button. Pills open a radio list, checkboxes with live counts, a two-thumb range or date presets with a calendar; narrow bars fold everything into one Filters sheet. Values are plain JSON that round-trips through the URL.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: `react-day-picker@^10`.
- Files: `components/ui/lumen/controls/filter-bar.tsx`; shared code: `lib/beautiful-ui/core/filters.ts`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `lumen-button`, `lumen-calendar`, `lumen-checkbox`, `lumen-input`, `lumen-popover`, `lumen-radio-group`, `lumen-sheet`, `lumen-slider`, `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: `FilterBar`, 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 { FilterBar } from "@/components/ui/lumen/controls/filter-bar";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `FilterBar` | — | Search, filter pills and their editors, and the narrow-screen sheet. |

## 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/controls/filter-bar.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
- filter bar, filters, faceted filters, search and filter, filter chips, table filters, date range filter, Lumen
- Above a table, list or chart whose rows people narrow by several fields

### Not when
- One on/off choice: use a Switch or Toggle Group
- Navigating between sections: use Tabs

## Mistakes
- Pass counts from facetCounts, not from all rows, or picking one option zeroes its neighbours
- Debounce the search on the server, not in the bar

## Usage

```tsx
import { FilterBar } from "@/components/ui/lumen/controls/filter-bar";
import { applyFilters, facetCounts } from "@/lib/filters";

const rows = applyFilters(accounts, fields, filters, accessors);
<FilterBar fields={fields} value={filters} onValueChange={setFilters} counts={facetCounts(accounts, fields, filters, accessors)} resultCount={rows.length} />
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `fields` | `FilterField[]` |  | What can be filtered: search, select, multi, range (min, max, step, unit) or date (presets). |
| `value / onValueChange` | `FilterValues` |  | Plain JSON. filtersToSearchParams / filtersFromSearchParams put it in the URL; a server can take it as it is. |
| `counts` | `Record<field, Record<option, number>>` |  | Option counts; facetCounts(rows, fields, value, accessors) computes them so each field's counts follow the other filters. |
| `resultCount` | `number` |  | Rows left, read politely as it changes. |
| `format` | `(n: number) => string` |  | Formats range numbers. |
| `collapseAt` | `number (px)` | `560` | Below this width of the bar itself, the pills fold into a Filters sheet. 0 never folds. |
| `density` | `"comfortable" \| "compact"` | `"comfortable"` | Compact pills and fields for dense toolbars. |
| `labels` | `Partial<Labels>` |  | Every word, for i18n. |

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

## 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 |
|---|---|
| Enter / Space | Open a filter's editor |
| Backspace / Delete | Clear the focused filter |
| Escape | Close the editor or the sheet |

## Motion inventory

| Interaction | What moves |
|---|---|
| Open an editor | The floating glass grows from its pill on the spring |
| Narrow bars | The Filters sheet rises from the bottom |

## Accessibility contract (preserve when editing)
- A search landmark; every pill is a button named with its field and value
- Each set pill has its own labelled clear button
- Options are real radios and checkboxes; counts are read after the option
- The result count is a polite live region

## Install

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

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 (https://ui.shadcn.com)

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.
