# Citation

An exhibit sticker in the text that opens the exact passage it cites, with a stamp saying whether the source checks out.

- Category: Documents
- Built from: Stamp and seal
- Docs: https://bevel-ui.vercel.app/components/citation
- Import from: `@/components/ui/citation`

## Install

```bash
npx shadcn@latest add @bevel/citation
```

npm dependencies (installed by the CLI): `@base-ui/react`, `cn`.

## Anatomy

```tsx
<Citation>
  <CitationTrigger>4</CitationTrigger>
  <CitationContent>
    <CitationSource />
    <CitationLocation />
    <CitationQuote />
    <CitationStatus status="verified" />
  </CitationContent>
</Citation>
```

## Parts

| Part | Renders | Description |
| --- | --- | --- |
| `Citation` | Popover | One cited source. open, defaultOpen, onOpenChange. |
| `CitationTrigger` | button | The exhibit sticker, inline in text: “Ex. 4”, read as “Exhibit 4”. tone: yellow, blue, white. abbreviation and label change the prefix. |
| `CitationContent` | Popover popup | The paper slip. Grows from the sticker; Escape closes it and returns focus. |
| `CitationSource` | Popover title | The source's name; titles the slip. |
| `CitationLocation` | p | Page, paragraph or clause. |
| `CitationQuote` | blockquote | The passage, highlighted. |
| `CitationStatus` | Stamp | verified, caution or unverified, always in words. Children replace the word. |

## Example: An answer with sources

Open a sticker to read the cited passage. The third source has been appealed.

```tsx
"use client"

import {
  Citation,
  CitationContent,
  CitationLocation,
  CitationQuote,
  CitationSource,
  CitationStatus,
  CitationTrigger,
} from "@/components/ui/citation"

/** An agent's answer with its sources pinned in. Open a sticker to read the passage. */
export function CitationAnswer() {
  return (
    <div className="max-w-md space-y-3 text-[0.9375rem] leading-relaxed">
      <p>
        The landlord can end the lease on thirty days&apos; notice
        <Citation>
          <CitationTrigger>1</CitationTrigger>
          <CitationContent>
            <CitationSource>Lease agreement, Harbor Street</CitationSource>
            <CitationLocation>p. 14, clause 9.2</CitationLocation>
            <CitationQuote>
              Either party may end this lease on thirty (30) days&apos; written notice.
            </CitationQuote>
            <CitationStatus status="verified" />
          </CitationContent>
        </Citation>
        , but notice must be written and delivered to the address in the schedule
        <Citation>
          <CitationTrigger>2</CitationTrigger>
          <CitationContent>
            <CitationSource>Lease agreement, Schedule B</CitationSource>
            <CitationLocation>p. 31</CitationLocation>
            <CitationQuote>Notices: 400 Harbor Street, Suite 12, attention of the Tenant.</CitationQuote>
            <CitationStatus status="verified" />
          </CitationContent>
        </Citation>
        .
      </p>
      <p>
        Courts have read similar clauses strictly
        <Citation>
          <CitationTrigger tone="blue">3</CitationTrigger>
          <CitationContent>
            <CitationSource>Marlow v. Pierce Holdings (2019)</CitationSource>
            <CitationLocation>¶ 42</CitationLocation>
            <CitationQuote>A notice not delivered as the lease requires is no notice at all.</CitationQuote>
            <CitationStatus status="caution">Appealed</CitationStatus>
          </CitationContent>
        </Citation>
        , so email alone may not count.
      </p>
    </div>
  )
}
```
