Sources
Inline citation markers and a source list that light each other, with hover previews of the cited passage.
New in 1.6.Built on Hover Card and Icons.
Installation
npx shadcn@latest add https://neonkit.heyaadi.com/r/sources.jsonUsage
import { Citation, SourceList, Sources } from "@/components/ui/sources"
<Sources sources={sources}>
<p>Postgres stores timestamptz as UTC<Citation index={2} />.</p>
<SourceList />
</Sources>Examples
Compact chips
variant="chips" keeps the list to one row of domains. Each chip previews its source on hover, and max folds the rest behind a +2 that moves focus to the first one it reveals.
Quoting the passage
quote replaces the source's snippet for one citation, so two markers on the same page can each show the sentence they rest on. Both markers for source 1 light together.
List on its own
SourceList takes sources directly when there are no inline markers.
API reference
Sources
Holds the sources for every Citation and SourceList inside it and links their light. Renders a div.
| Prop | Type | Default |
|---|---|---|
sources | Source[]In citation order: index 1 is the first. A Source is { title, url, domain?, snippet?, date?, meta? }. | None |
color | NeonColorPalette name or hex. Falls back to --neon-accent, then cyan. | inherited |
Source
| Prop | Type | Default |
|---|---|---|
title | stringThe page or document title. | None |
url | stringWhere the marker and list item link. http(s) links open in a new tab. | None |
domain | stringShown instead of the host, without www. | url host |
snippet | stringA passage from the page. Two lines in the list, four in the preview. | None |
date | stringISO date, 2024-09-26, or 2002-07 for a month. Printed as Sep 26, 2024 or Jul 2002. | None |
meta | stringA short qualifier after the domain: RFC 9110, Issue #2141, PostgreSQL 17. | None |
Citation
An anchor. Other anchor attributes pass through.
| Prop | Type | Default |
|---|---|---|
index | number1-based position in the surrounding sources. | None |
source | SourceThe source, when the citation isn't inside Sources. | None |
quote | stringThe passage this claim rests on. Replaces the snippet in the preview. | None |
preview | booleanOpen a preview card on hover and keyboard focus. | true |
color | NeonColorPalette name or hex. | inherited |
SourceList
An ordered list. Other list attributes pass through.
| Prop | Type | Default |
|---|---|---|
variant | "list"list prints title, domain, date and snippet. chips prints the domain and previews the rest. | "list" |
sources | Source[]The sources, when the list isn't inside Sources. | None |
max | numberChips only: how many to show before a +n button. | None |
label | stringAccessible name of the list. | "Sources" |
color | NeonColorPalette name or hex. | inherited |
Accessibility
- Each marker is a link named after its source, "Source 2: 8.5. Date/Time Types (postgresql.org)", so a screen reader reads more than a number.
- Tab to a marker to open its preview; the open card describes the marker through aria-describedby, and Escape closes it.
- Markers are inline text set directly after the word, so a number never starts a line on its own.
- The list is an <ol>, so its numbers match the markers for people who can't see the plates.
- Light is state only: a marker, its plate in the list and its row light while either is hovered or focused, and decay over 300ms.