Skip to content
pandacoderz/ui

Citation

Inline numbered citation chips with hover previews, plus source cards for answer-with-sources layouts.

Installation

npx shadcn@latest add https://ui.spencerwueste.com/r/citation.json

Usage

import { Citation, CitedText, SourceCard, SourceList, type Source } from "@/components/pandacoderz-ui/citation";

CitedText is the fast path: give it a paragraph containing [1], [2] markers and the matching sources array.

<CitedText text="Astro hydrates only islands [1]." sources={sources} activeId={active} onHover={setActive} />
<SourceList>
  {sources.map((s, i) => <SourceCard key={s.id} index={i + 1} source={s} active={active === s.id} />)}
</SourceList>

For full markdown, keep the [n] markers in the model output and render <Citation> yourself from a custom paragraph or text renderer.

API Reference

Source

Field Type Description
id string Stable key used for hover linking.
title / url string Required.
snippet string Shown in the tooltip and card.
site string Publisher name. Derived from the URL hostname when omitted.
date string Optional trailing date on the card.

Citation

Prop Type Description
index number Display number.
source Source Enables the link and hover preview.
active boolean Highlighted state.