AI Response with Cited Sources
An AI chat answer broken into segments with inline numbered citation markers woven into the text. Below the answer, a source panel lists each referenced URL with a title, a globe icon, and an expandable preview snippet. Clicking a citation marker highlights its matching source row.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its badge dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/ai-response-with-cited-sources.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/chat/chat6.tsx instead.
Usage
The file also exports chat6Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Chat6, chat6Demo } from "@/components/blocks/chat/chat6"; export default function Page() { return <Chat6 {...chat6Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Answer" | Small heading shown in the panel header. |
| responseParts | ResponsePart[] | none | Ordered text segments making up the answer; a segment can carry a `citation` number to render an inline marker after it. |
| sources | CitedSource[] | none | Sources listed below the answer, in citation order (index + 1 = citation number). |
| className | string | none | Extra classes for the outer panel element. |
Types
export interface ResponsePart { text: string; citation?: number; } export interface CitedSource { id: string; title: string; url: string; snippet: string; }
Behavior notes
- Citation markers are real, interactive buttons: clicking one sets an `activeCitation` useState and highlights the matching source row (border-primary + muted background), rather than being purely presentational.
- Each source's preview snippet expands/collapses independently via a `Set<string>` of expanded ids in useState, with a real `aria-expanded` toggle button.
- Favicons are skipped in favor of a plain lucide-react Globe icon per source, so nothing depends on fetching external favicon images.
- No actual citation-to-answer scrolling or real search happens, this is a static demo dataset.
More Chat Blocks
View all →rich-prompt-input-with-suggestions
Rich Prompt Input with Smart Suggestions
An AI prompt composer with attachment icons, a model selector, and a grid of clickable prompt suggestion cards.
ai-streaming-response-typewriter
AI Streaming Response with Live Typing
A single AI chat exchange with a skeleton loading state, a word-by-word typewriter reveal, and a stop-generating control.
code-generation-chat-with-syntax-highlighting
Code Generation Chat with Syntax Highlighting
A developer chat message with a file-name tab bar, a language badge, illustrative syntax coloring, and a real copy button.
prompt-starter-grid
AI Prompt Starter Grid
A tabbed grid of prompt template cards, filterable by category, each with an icon, title, and description.
ai-agent-profile-card
AI Agent Profile Card
A showcase card for an AI agent with avatar, capability badges, a sample chat preview, stats, and action buttons.
floating-chat-widget
Floating Chat Widget with Expandable Window
A corner chat bubble with a pulsing notification dot that expands into a mini chat window.