Citations
Citations uses citation IDs and prefixes to connect markers and source entries.
Practical React example
Connect inline source markers to a readable list of references.
Before you copy and paste
Keep the example in the React rendering environment required by the imported component. Copy components/agents/citations.tsx and its returned support files from the Code tab; preserve the project-relative paths.
Listed package dependencies: clsx, lucide-react, motion, react, tailwind-merge.
Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.
Connect inline source markers to a readable list of references
// Usage adapted from beUI's pinned MIT source.
// Copyright (c) 2026 Saurabh Chauhan. See ./LICENSES.md.
"use client";
import { RotateCcw } from "lucide-react";
import { useReducedMotion } from "motion/react";
import { useEffect, useState } from "react";
import {
Citation,
Citations,
type CitationItem,
} from "@/components/agents/citations";
const CITATION_ITEMS: CitationItem[] = [
{
id: "motion",
title: "Motion documentation",
domain: "motion.dev",
url: "https://motion.dev/docs/react",
},
{
id: "wai",
title: "WAI accessibility patterns",
domain: "w3.org",
url: "https://www.w3.org/WAI/ARIA/apg/",
},
{
id: "react",
title: "React documentation",
domain: "react.dev",
url: "https://react.dev/learn",
},
];
function CitationsDemo() {
const reduce = useReducedMotion() ?? false;
const [visible, setVisible] = useState(reduce ? CITATION_ITEMS.length : 0);
useEffect(() => {
if (reduce) return;
const timers = CITATION_ITEMS.map((_, index) =>
window.setTimeout(() => setVisible(index + 1), 500 + index * 700),
);
return () => timers.forEach(window.clearTimeout);
}, [reduce]);
return (
<div className="space-y-4">
<p className="text-sm leading-6 text-foreground/90">
Use layout-aware motion for newly appended results{" "}
<Citation citationId="motion" index={1} idPrefix="preview-source" /> and preserve accessible
disclosure behavior <Citation citationId="wai" index={2} idPrefix="preview-source" /> as the list
grows.
</p>
<Citations
idPrefix="preview-source"
citations={CITATION_ITEMS.slice(0, visible)}
defaultOpen
/>
</div>
);
}
export function CitationsPreview() {
const [run, setRun] = useState(0);
return (
<div className="relative h-[410px] w-full max-w-lg">
<CitationsDemo key={run} />
<button
type="button"
onClick={() => setRun((value) => value + 1)}
className="absolute bottom-0 left-0 inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
>
<RotateCcw className="size-3" />
Replay
</button>
</div>
);
}
Usage example adapted from beUI's pinned MIT source. Retain the source licence notices when copying.
Keep citationId aligned with the referenced item and use a unique idPrefix for each response. Supply trustworthy titles and URLs from the retrieval layer.
Customization
- CitationsProps.citations
- Required; CitationItem[].
- CitationsProps.title
- Optional; ReactNode.
- CitationsProps.open
- Optional; boolean.
- CitationsProps.defaultOpen
- Optional; boolean.
- CitationsProps.onOpenChange
- Optional; (open: boolean) => void.
- CitationsProps.idPrefix
- Optional; string.
- CitationsProps.className
- Optional; string.
- CitationProps.citationId
- Required; string.
- CitationProps.index
- Required; number.
- CitationProps.idPrefix
- Required; string. Must match the related Citations idPrefix.
- CitationProps.className
- Optional; string.
- CitationListProps.citations
- Required; CitationItem[].
- CitationListProps.idPrefix
- Optional; string.
- CitationListProps.className
- Optional; string.
Integration notes
- A citation marker is not proof that a source supports the associated claim.
- Validate allowed URL schemes and keep source links accessible without hovering.
Component source: beUI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.
Give your agent taste.
The best way to use Rendyn is through MCP. Let your agent find the right component, compare previews and bring the source into your project.
All components are free. Sign up only to connect MCP.