Citation
An inline numbered source that previews the site, title and snippet on hover or focus.
Used forAI answers with sourcesResearch and search toolsDocumentation assistantsReports and articles
Part of AI chat components for React, the parts of a chat in the order they appear.
Install with the shadcn CLI
Registered the namespace? Then it’s shadcn add @hairline/citation. Set it up
Templates
Need the whole page?
63 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
AI answers with sources
Numbered markers inside the sentences of a chatbot answer.
Research and search tools
Answers where each claim points to the page it came from.
Documentation assistants
Show which docs page an answer was taken from.
Reports and articles
Footnote-style references that preview the source in place.
What it handles for you
Answers that cite sources earn trust, but a wall of links at the bottom gets ignored. This puts the source right next to the claim it supports.
A marker in the sentence
A small numbered marker that sits on the text’s baseline, where the claim is.
A preview of the source
Hover or focus it to see the site, the title and a snippet.
It stays on screen
The card flips above near the bottom of the screen and shifts to stay inside it.
It opens the source
The marker is a real link, so middle-click and Ctrl-click work.
Broken sources say so
A source that couldn’t be fetched is struck through and the card explains it.
No flicker
Short open and close delays stop cards flashing as the pointer crosses a paragraph. Escape closes it.
Overview
Answers that cite sources earn trust, but a wall of links at the bottom gets ignored. This puts a small numbered marker right in the sentence. Hover or focus it and a card rises out of a light blur to show where the claim comes from, then sinks back when you leave; click and the source opens. The card flips above near the bottom of the screen and shifts to stay on it, and a source that couldn’t be fetched says so instead of failing quietly.
States
- closed
- A quiet numbered marker that sits on the text’s baseline.
- open
- After a short hover delay, or at once on focus: site, title and a snippet. The card rises 4px out of a 2px blur (220ms) and sinks back the same way when it closes (140ms).
- unavailable
- The marker is struck through and the card says the source couldn’t be loaded.
Usage
Depends on lucide-react, installed for you by the CLI along with the keyframes it needs.
With the AI SDK
Map the Vercel AI SDK’s message parts and chat status onto the component’s props.
Props
- index
- number
- The number shown in the marker.
- source
- { title; url; snippet?; icon? }
- What the card shows. icon takes a favicon element; a globe is shown without one.
- status= "available"
- "available" | "unavailable"
- Unavailable (or no source) strikes the marker and explains in the card.
Accessibility and motion
- The marker is a real link, so middle-click and Ctrl-click work, and it’s labelled "Source 1: title".
- The card is a tooltip linked with aria-describedby; it opens on keyboard focus and closes on Escape.
- Short open and close delays stop cards flickering as the pointer crosses a paragraph.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
Source
Registry item: /r/citation.json


