# Citation

An inline [n]. Opens the source in a popover on click or Enter, so evidence is one step away without leaving the thread. A source the message doesn't list renders as a plain bracket rather than a guess.

- Registry name: `citation` (`@candor/citation`)
- Tier: Free (MIT). No licence key needed.
- Docs: https://candor.themethodic.com/docs/citation

## Install

```bash
npx candor-ui add citation
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/citation`.
It brings in: chat, locale, popover, utils.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import { Citation, SourceList } from "@/components/citation"
import type { MessageSource } from "@/lib/chat"

const sources: MessageSource[] = [
  { id: "s1", marker: 1, kind: "document", label: "Returns policy", origin: "Help centre", snippet: "Items can be returned within 30 days of delivery." },
  { id: "s2", marker: 2, kind: "query", label: "Order #4821", origin: "Orders database" },
]

export default function Example() {
  return (
    <div className="flex max-w-lg flex-col gap-3 text-sm">
      <p>
        You can return it until 14 December <Citation source={sources[0]} /> since it was delivered on 14 November <Citation source={sources[1]} />.
      </p>
      <SourceList sources={sources} />
    </div>
  )
}
```

## <Citation>

Props:

- `source?: MessageSource | undefined`: The source this marker points to; without it the marker says it's unknown.
- `marker?: number | undefined`: The number to show when there's no source.

## <SourceList>

The sources under a reply, as chips that open the same detail.

Props:

- `sources: MessageSource[]`: Every source the reply used, in marker order.
- `className?: string | undefined`

## <SourceDetail>

Props:

- `source: MessageSource`: The source this marker points to; without it the marker says it's unknown.

## Strings (`citation`)

The fixed words, English by default. Override any of them under `citation` in `<LocaleProvider strings={{ citation: { … } }}>`; the table is exported as `citationStrings`.

- `document`: Document
- `web`: Web page
- `query`: Query
- `data`: Data
- `code`: Code
- `workflow`: Workflow
- `knowledge`: Knowledge
- `source`: Source
- `notVerified`: The agent cites this but hasn’t verified it.
- `sourceLabel`: Source {marker}: {label}
- `sources`: Sources

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
