Skip to content
AgentsSourcesMenu

Sources

The sources behind an answer: a stack of letter tiles and a count, expanding to a numbered list that matches the citations.

Collapsed with stacked tiles, expanded as a numbered list.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/sources.json

Usage

tsx
import { Sources, sourcesFromParts } from "@/components/ui/chatcn/sources"

<Sources sources={sourcesFromParts(message.parts)} />

Tiles show the domain's first letter on gray, so a row of sources stays as calm as the text around it. Pass favicon to show a real one; a broken image falls back to the letter.

Props

PropTypeNotes
sourcesSource[]{ url, title?, snippet?, domain?, favicon?, id? }
labelReactNodeDefaults to 12 sources
maxTilesnumberTiles in the stack. Default 4
open, defaultOpen, onOpenChangeCollapsed by default

Keyboard

KeyAction
Enter, SpaceExpand or collapse the list
TabMove through the sources. Each opens in a new tab

Accessibility

  • The list is ordered, so its numbers are real list positions. Tiles are decorative and hidden from screen readers.

Motion

  • The list opens over 200 ms. Hover changes background color only.