# Toggle Group (Lumen Halo): prompt.md (v1.0.0)

- id: `lumen-toggle-group` · version 1.0.0 · component · pro (All-Access)
- category: Actions
- build: Base UI (this item also ships a Radix build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/lumen-toggle-group`
- npm dependencies: @base-ui/react@^1, class-variance-authority@^0.7
- registry dependencies: utils, @beautiful-ui/lumen-toggle, https://beautiful-ui.dev/r/lumen-foundation.json
- docs: https://beautiful-ui.dev/components/lumen-toggle-group
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

Pick one and watch the glass thumb glide to it, or pick several as chips: the segmented control and filter row every analytics screen needs. shadcn's ToggleGroup, cut from Lumen glass.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: `@base-ui/react@^1`, `class-variance-authority@^0.7` (Base UI build); `class-variance-authority@^0.7`, `radix-ui@^1` (Radix build).
- Files: `components/ui/lumen/toggle-group.tsx`; shared code: `lib/beautiful-ui/lumen/indicator.ts`, `lib/beautiful-ui/lumen/sound.ts`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `lumen-toggle`, `lumen-foundation`.
- Builds: separate Base UI and Radix files. 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: `ToggleGroup`, `ToggleGroupItem`, 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-sans`, `--lumen-radius-k`. Never add Tailwind colour classes inside the component.

```tsx
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/lumen/toggle-group";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `ToggleGroup` | `toggle-group` | The track or the chip row. |
| `ToggleGroupItem` | `toggle-group-item` | One item, a Lumen Toggle. |

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; `sound={false}` silences one instance.
- This item: select, pitched by position; or toggle-on and toggle-off.

## Match the original
- Read `components/ui/lumen/toggle-group.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
- toggle group, segmented control, button group, range picker, day week month, filter chips, shadcn toggle group, Lumen
- Choosing a range or a view: Day, Week, Month (spacing={0}, the segmented control)
- Several filters at once: platforms, segments (multiple)
- A drop-in for shadcn's ToggleGroup

### Not when
- Switching whole panels of content: use Lumen Tabs
- A form choice with descriptions: use Lumen Radio Group

## Mistakes
- Give the group an aria-label: it names the choice
- Keep a value selected for a range picker (ignore the empty change)
- Import from @/components/ui/lumen/toggle-group: it never replaces your own

## Usage

```tsx
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/lumen/toggle-group";

<ToggleGroup spacing={0} value={range} onValueChange={setRange} aria-label="Group by">
  <ToggleGroupItem value="day">Day</ToggleGroupItem>
  <ToggleGroupItem value="week">Week</ToggleGroupItem>
</ToggleGroup>
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `value / defaultValue / onValueChange` | `string[] (Base UI) · string or string[] (Radix)` |  | As each primitive, like shadcn. |
| `multiple (Base UI) · type (Radix)` | `boolean · "single" \| "multiple"` |  | One choice (the thumb glides) or several (each tints). |
| `spacing` | `number` | `2` | 0 is the segmented glass track; above that, separate chips (× 0.25rem). |
| `variant / size / orientation` | `as shadcn` |  | Passed to every item. |
| `sound` | `boolean` | `true` | Beautiful UI: one choice plays select pitched by position; several play toggle-on and toggle-off. |

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

## 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 |
|---|---|
| Arrow keys | Move between items |
| Space / Enter | Press the focused item |

## Motion inventory

| Interaction | What moves |
|---|---|
| Choose (one) | The glass thumb glides to the item (.6s, cubic-bezier(.22,1,.36,1)) |
| Choose (several) | Each item tints with the accent |
| Sound | select, pitched by position; or toggle-on and toggle-off |

## Accessibility contract (preserve when editing)
- role=group of toggle buttons with aria-pressed, arrow-key navigation, from Base UI or Radix
- Label the group with aria-label
- The gliding thumb is decoration; aria-pressed carries the state

## Install

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

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.
