Conversation
Source List
Citations behind an answer — numbered footnotes with hover previews and a panel of every source used.
Preview
Installation
Copies the component into components/ui and installs its dependencies and theme tokens.
pnpm dlx shadcn@latest add https://uilab.tmih06.com/r/source-list.jsonUsage
Pass your own data and wire the callbacks to your agent runtime.
import { SourceList } from "@/components/ui/source-list";
// The model writes markers like [1] or [2, 3] that index into the sources it used.
// Pass null explicitly until the answer and citation payload resolves.
export function CitedAnswer({ query }: { query: AnswerQuery }) {
return (
<SourceList
data={query.data ? { text: query.data.text, sources: query.data.sources } : null}
loading={query.isRefetching}
skeleton={{ count: 4 }}
/>
);
}
export function SourcesTab({ answer }: { answer: Answer }) {
return (
<SourceList
variant="panel"
data={{ sources: answer.sources, claims: answer.claims }}
onOpen={(source) => analytics.track("source_opened", { url: source.url })}
/>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| data* | SourceListData | null | — | Sources in citation order, plus the answer text with [n] markers (footnotes) or the claims each source supports (panel). Pass null while they load. |
| loading | boolean | false | Force the layout-preserving skeleton while refetching, even when stale source data is available. |
| skeleton | { count?: number } | — | Shape hints for the loading state; count is the number of source placeholders before the real cardinality is known. |
| variant | "footnotes" | "panel" | "footnotes" | Inline markers with hover previews and a compact numbered list, or a panel grouped by site showing which claims each source backs. |
| onOpen | (source: Source) => void | — | Called when a source link is opened. |
| labels | Partial<SourceListLabels> | — | Your own UI strings (the labels.loading announcement, Sources, the panel title and counts…), for translating. Right-to-left works under `dir="rtl"`. |
| className | string | — | Extra classes for the root element. |
type Source = { id: string; title: string; url: string; snippet?: string; date?: string };
type SourceListData = {
sources: Source[];
text?: string; // "… [1] … [2, 3]"
claims?: { id: string; text: string; sourceIds: string[] }[];
};