Citation
Numbered source chips for AI answers. Hover one to see where a claim came from, or open the sources list to see them all.
Preview
Setup
Install with the shadcn CLI
One command adds every file, the npm packages and any Kinetik components it builds on. Needs a components.json; the CLI offers to create one if your project has none.
Or install manually
- 1
Run in your terminal:
$npm install clsx tailwind-merge framer-motion lucide-react @radix-ui/react-slot class-variance-authority - 2
Copy
lib/utils.tsfrom the Code tab. Skip if you already havecn(). - 3
Copy
styles/tokens.cssfrom the Code tab and import it in your global CSS after Tailwind:@import "./styles/tokens.css"; - 4
This component uses Button. Copy
components/ui/button/from the Code tab too, at the same path so the import resolves. Skip any you already have. - 5
Create a
components/ui/citation/folder and copy every file from the Code tab into it. Each file does one job, so you can read or change a piece without the rest. - 6
Import and render:
Exampleimport { Citation } from "@/components/ui/citation" <p>The sky is blue <Citation index={1} source={{ title: "Rayleigh scattering", url: "https://example.com" }} /></p>
Usage
Put a Citation right after the sentence it backs up. Pass the source directly:
import { Citation } from "@/components/ui/citation"
<p>
Water absorbs red light
<Citation index={1} source={{ title: "Why the ocean is blue", url: "https://…", snippet: "…" }} />
</p>When a reply has several sources, wrap it in CitationProvider once. Each chip then
finds its own source by number, so index={2} shows sources[1]:
import { Citation, CitationProvider, CitationSources } from "@/components/ui/citation"
<CitationProvider sources={sources}>
<CitationSources sources={sources} />
<p>
Water absorbs red light <Citation index={1} />. Scattering adds to it <Citation index={2} />.
</p>
</CitationProvider>CitationSources is the “3 sources” pill with stacked site icons. Click it to see every source as a card.
Each site icon uses favicon when you pass it. Without one, it shows the first letter of the domain in a color picked from the domain name.
Props
Citation
| Prop | Type | Default | What it does |
|---|---|---|---|
index | number | — | The number in the chip, starting at 1. |
source | CitationSource | from provider | The source to show. Optional inside CitationProvider. |
flicker | boolean | true | A flickering grid in the card's top-right corner. |
flickerColor | string | accent | Colour of the flickering squares. Any CSS colour or var(). |
CitationSources
| Prop | Type | Default | What it does |
|---|---|---|---|
sources | CitationSource[] | — | Every source in the reply. |
defaultOpen | boolean | false | Start with the cards showing. |
max | number | 4 | How many icons to stack in the pill. |
CitationSource
| Field | Type | What it is |
|---|---|---|
title | string | Page title. |
url | string | Link to the page. The domain is read from it. |
snippet | string? | A short quote shown in the hover card. |
favicon | string? | Site icon URL. |
siteName | string? | Shown instead of the domain. |
Accessibility
- Each chip is a link labelled “Source 1: title”, and it opens in a new tab
- The card opens on keyboard focus as well as hover, and Escape closes it
- The sources pill is a button that says whether the list is open (
aria-expanded)