Citation
Inline source reference pill for RAG and AI answers that opens a keyboard- and touch-accessible preview popover with the source domain, external title link and optional excerpt.
Preview
Usage
When to use
- Attach inline numbered source references to RAG or AI answers with a keyboard- and touch-accessible preview.
- Let readers verify the source domain, title and excerpt before opening an external link.
When not to use
- Standard navigation links in prose. Use Link.
- Design token names or short machine values. Use Token.
- Hover-only previews that do not need touch activation. Use HoverCard.
Examples
Inline citations
Compact numbered pills inside an assistant answer that open a source preview popover on press.
With domain in the pill
showDomain displays the host beside the reference index inside the inline pill.
Without an index
When index is omitted, the pill falls back to displaying the source domain.
Do and don't
Do
- Place compact `[1]` citations inline at the end of the claim they support.
- Include a short `snippet` so readers can verify the source before leaving the page.
- Always pass a descriptive `title` so screen readers and preview cards name the source clearly.
Don't
- Do not pack long paragraphs into `snippet`; keep excerpts to one or two sentences.
- Do not use `Citation` for general navigation links; use Link.
Props
| Name | Type | Values | Default | Description |
|---|---|---|---|---|
| index | number | string | - | - | Optional reference number or marker shown inside the inline pill, such as `1`. |
| title required | string | - | - | Required source title shown as the external link in the preview popover and used in the trigger `aria-label`. |
| href required | string | - | - | Required source URL opened by the external link and used to derive `domain` when omitted. |
| domain | string | - | - | Optional short host label. Derived safely from `href` when omitted. |
| snippet | node | - | - | Optional quoted excerpt shown inside the preview popover. |
| showDomain | boolean | - | false | Shows the domain text beside the index inside the inline pill. When `false`, the pill shows `index`, or `domain` if `index` is omitted. |
| open | boolean | - | - | Controlled open state of the preview popover. Pair with `onOpenChange`. |
| defaultOpen | boolean | - | false | Initial open state when uncontrolled. |
| onOpenChange | (open: boolean) => void | - | - | Called with `true` or `false` when the preview popover opens or closes. |
Anatomy
| Part | Description |
|---|---|
| root | The inline pill button: `size-inline-sm` (20px) tall, `radius-full`, gray fill and monospace secondary text. |
| hitArea | Transparent `::before` centered on the pill, never smaller than `size-target-min` (24px on mouse, 44px on touch). |
| content | The Popover panel holding the source domain, external title link and optional excerpt. |
| domain | Host label and external-link icon at the top of the preview card in tertiary text. |
| link | Underlined external link for the source title inside the preview card (`target="_blank"` and `rel="noopener noreferrer"`). |
| snippet | Optional quoted excerpt in small secondary text inside the preview card. |
Accessibility
Role: button
| Keys | Action |
|---|---|
| Enter, Space | Opens or closes the source preview popover. |
| Tab | Moves focus to the external link inside the open popover. |
| Escape | Closes the popover and returns focus to the citation pill. |
- The trigger defaults its `aria-label` to `${title} (${domain})` so compact `[1]` pills remain meaningful to screen readers.
- The 20px pill extends its touch target to `size-target-min` (44px on touch) via a centered transparent `::before` pseudo-element.
Install
npx werewolf-ui add https://www.werewolf-ui.dev/r/citation.jsonRun npx werewolf-ui init once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See Installation for requirements and the alternative registry setup.