# Citations (Lumen Halo): prompt.md (v1.0.0)

- id: `lumen-citations` · version 1.0.0 · component · pro (Pro)
- category: AI interfaces
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/lumen-citations`
- npm dependencies: none
- registry dependencies: utils, @beautiful-ui-pro/lumen-hover-card, https://beautiful-ui.dev/r/lumen-foundation.json
- docs: https://beautiful-ui.dev/components/lumen-citations
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

Where an answer's claims come from: a small numbered chip in the text opens a card with the site, title and the passage used; Sources lists them all under the answer, folding a long list after a few.

## 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/controls/citations.tsx`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `lumen-hover-card`, `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: `Citation`, `Sources`, 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-foreground`, `--lumen-accent-text`, `--lumen-bad`, `--lumen-bad-text`, `--lumen-chart-accent`, `--lumen-chart-accent-foreground`, `--lumen-chart-accent-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 { Citation, Sources, type CitationSource } from "@/components/ui/lumen/controls/citations";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `Citation` | — | The numbered chip in the text and its card (citation-card). |
| `Sources` | — | The list of sources (each citation-source). |

## 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/citations.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
- AI citations, inline sources, footnotes in an answer, source list, retrieval augmented answer, Lumen
- Answers grounded in documents or the web (RAG, search)
- Any generated text whose claims should be checkable

### Not when
- A long reference list on a document page: use a plain ordered list
- Evidence behind a recommendation: use Evidence Panel

## Mistakes
- Number chips in order of first use and keep Sources in the same order
- Only cite what the answer used: a snippet the reader can match builds trust

## Usage

```tsx
"use client";

import { Citation, Sources, type CitationSource } from "@/components/ui/lumen/controls/citations";

const sources: CitationSource[] = [
  { id: "a", title: "Quarterly report, Q3", url: "https://example.com/reports/q3", snippet: "Revenue grew 12% year on year, led by the enterprise tier." },
  { id: "b", title: "Churn dashboard notes", url: "https://example.com/notes/churn", publisher: "Internal wiki" },
];

export function GroundedAnswer() {
  return (
    <div className="flex flex-col gap-4 text-sm leading-6">
      <p>
        Revenue grew 12% year on year
        <Citation index={1} source={sources[0]!} />, while churn held at 1.8%
        <Citation index={2} source={sources[1]!} />.
      </p>
      <Sources sources={sources} />
    </div>
  );
}
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `Citation index / source` | `number / CitationSource` |  | The number in the text and the source: { id, title, url, snippet?, publisher?, icon? }. |
| `Sources sources` | `CitationSource[]` |  | All sources, in citation order. |
| `Sources collapseAfter` | `number` | `4` | Show this many, then Show all (0 never folds). |
| `Sources heading` | `ReactNode` | `"Sources"` | The list's heading. |
| `labels` | `Partial<CitationLabels>` |  | chip(index, title), open, sources, showAll(n), showFewer. |

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

## 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 |
|---|---|
| Tab | Reach a chip (its card opens) or a source |
| Enter | Open the source in a new tab |

## Motion inventory

| Interaction | What moves |
|---|---|
| Card | Hover Card's fade and rise; the chip lifts in contrast while it's open |

## Accessibility contract (preserve when editing)
- Each chip is a link named "Source 2: its title", so the number is never read alone
- The card opens on focus as well as hover; the link inside it opens the source
- Sources is a labelled section with an ordered list; Show all is a button with aria-expanded

## Install

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

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.
