Command Palette

Search for a command to run...

Sources

shadcn/ui

Collapsible reference list rendering external links cited by an agent reply.

Sources

import {	Source,	Sources,	SourcesContent,	SourcesTrigger,} from "@/components/optics/ai-elements/sources";interface SourceEntry {	title: string;	href: string;	description: string;}const DEMO_SOURCES: readonly SourceEntry[] = [	{		title: "Next.js App Router Documentation",		href: "https://nextjs.org/docs/app",		description: "File-system routing, layouts, and Server and Client Component boundaries.",	},	{		title: "Base UI Collapsible Primitive",		href: "https://base-ui.com/react/components/collapsible",		description: "Accessible collapsible root, trigger, and animated panel primitives.",	},	{		title: "shadcn/ui AI Elements",		href: "https://ui.shadcn.com/docs/ai-elements/base/sources",		description: "Reference patterns for displaying cited external links in agent replies.",	},];function SourcesDemo() {	return (		<div className="w-full max-w-md rounded-xl border bg-card p-4">			<Sources defaultOpen>				<SourcesTrigger count={DEMO_SOURCES.length} />				<SourcesContent>					{DEMO_SOURCES.map((source) => (						<Source							key={source.href}							href={source.href}							title={source.title}							description={source.description}						/>					))}				</SourcesContent>			</Sources>		</div>	);}<SourcesDemo />

Installation

pnpm dlx shadcn@latest add @optics/ai-sources

Props

<Sources />
Name
Type
open
boolean
defaultOpen
boolean(default: false)
onOpenChange
(...args) => void

<SourcesTrigger />
Name
Type
count
number
icon
React.ReactNode
render
React.ReactElement
nativeButton
boolean
<SourcesContent />
Name
Type
render
React.ReactElement
hiddenUntilFound
boolean
keepMounted
boolean
forceMount
boolean
<Source />
Name
Type
href
string
description
React.ReactNode
icon
React.ReactNode
target
React.HTMLAttributeAnchorTarget(default: _blank)
rel
string(default: noreferrer)