---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Citation

A source's small numbered chip inside an AI answer's words, right after the claim it backs, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `Citation`.

## When to use

- A source's small numbered chip inside an AI answer's words, right after the claim it backs.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Citation on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-citation.json --yes
```

```text
Add the Goop Citation to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { ChatMessage } from '@/components/ui/goop/chat-message';
import { Citation, CitationList, type CitationSource } from '@/components/ui/goop/citation';

const recordings: CitationSource = {
  title: 'How long session recordings are kept',
  site: 'help.fieldwork.example',
  href: '/help/recordings',
};
const plan: CitationSource = {
  title: 'Diallo Dental: study plan',
  site: 'fieldwork.test',
  href: '/studies/diallo',
  icon: 'file-text',
};

function Answer() {
  return (
    <ChatMessage author="Assistant" time="09:41">
      <p>
        Recordings are deleted 90 days after a study closes.
        <Citation index={1} source={recordings} /> The Diallo Dental plan keeps them for 30 days.
        <Citation index={2} source={plan} />
      </p>
      <CitationList sources={[recordings, plan]} />
    </ChatMessage>
  );
}
```

- Fits: chat (its recipe).
- Put the answer's words with their Citation chips in a ChatMessage's children, and the same sources, in the same order, in a CitationList row after the words; the chip numbered 2 cites the row's second source.
- CitationList: Under the answer's words in a ChatMessage's children, with the inline Citation chips in the words numbered as this row; for plain document chips with no site or preview, ChatMessage's own `sources` is enough.
- height, width, padding, gap, corner, background, text, motion: add no class for these.

## API reference

### Options

- `previewOpen?: boolean` — The card shown (controlled); pair it with `onPreviewOpenChange`.
- `onPreviewOpenChange?: (open: boolean) => void` — Called with the card's new open state.
- `container?: HTMLElement | null` — Where the card is portalled; the end of `<body>` when left out.
- `index: number` — The source's number in its answer (1, 2, …), shown on the chip and said in its name.
- `source: CitationSource` — The source the chip cites.
- `onOpen?: (source: CitationSource) => void` — Open the source yourself (a side panel of your own): the chip becomes a button that calls it with the source.
- `target?: HTMLAttributeAnchorTarget` — Where the link opens (`_blank`: a new tab, with its `rel`); a link alone.
- `sourceLabel?: string = 'Source'` — The word before the number in the chip's name ("Source").
- `className?: string` — Your classes on the chip.

- State: previewOpen (previewOpen / onPreviewOpenChange); drawn by data-state=open
- Types: CitationSource = { id?: string; title: string; site: string; href: string; icon?: IconName }

### Parts

- `CitationList` — The row of an AI answer's sources under its words; its props: citation--list.md

- data-slot values (to select a part by): citation, citation-caption, citation-caption-icon, citation-content, citation-item, citation-item-label, citation-item-title, citation-list, citation-title

### CitationList

The row of an AI answer's sources under its words.

```tsx
import { CitationList } from '@/components/ui/goop/citation';
```

### Options

- sources: readonly CitationSource[] — The answer's sources, in the order its chips number them (the first is 1).
- onOpen?: (source: CitationSource) => void — Open a source yourself: every chip becomes a button that calls it with its source.
- target?: HTMLAttributeAnchorTarget — Where the links open (`_blank`: a new tab, with its `rel`).
- label?: string = 'Sources' — The row's name for a screen reader ("Sources").
- sourceLabel?: string = 'Source' — The word before each number in a chip's name ("Source").
- className?: string — Your classes on the row.
- Types: CitationSource = { id?: string; title: string; site: string; href: string; icon?: IconName }

## Keyboard

- Enter: follow the link to the source (with onOpen, Enter or Space hands the caller the source)
- Tab: move to the next chip: the answer's inline chips in their words' order, then the row's chips; the keyboard's focus on a chip shows its card
- Escape: close the chip's card; the focus stays on the chip

## Accessibility

- The native element answers the keyboard.
- hover, active, focus-visible: the browser's own (:hover, :active, :focus-visible): write nothing
- expanded: the attribute data-state=open
- open: the attribute data-state=open

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Chat message](/themes/meadow/components/chat-message): One message of a conversation: its author, its body and when it was sent, often an avatar and actions.
- [Color swatch](/themes/meadow/components/color-swatch): One colour pill, to pick a colour from a row of them or to show one on a menu's trigger.
- [Comment thread](/themes/meadow/components/comment-thread): A record's discussion: replies, reactions, resolve.
- [Draft email card](/themes/meadow/components/draft-email-card): An email an assistant drafted, ready to send, for a page's column or a chat's reply.
