Citation chips and grouped source lists for AI responses.
Use ChatSource to cite a link or a file next to an answer.
import {ChatSource, ChatSources} from "@heroui-pro/react";
<ChatSource href={href} title={title}>
<ChatSource.Trigger>
<ChatSource.Icon /> {/* Optional */}
<ChatSource.Title />
</ChatSource.Trigger>
<ChatSource.Preview /> {/* Optional */}
</ChatSource>;
<ChatSources>
<ChatSources.Trigger>{/* ... */}</ChatSources.Trigger>
<ChatSources.Content>
<ChatSources.List>{/* ... */}</ChatSources.List>
</ChatSources.Content>
</ChatSources>;Use ChatSources to fold many sources behind a trigger, such as stacked favicons and a count.
Set maxVisible on ChatSources.List to show the first sources and a "+N more" chip. The chip reveals the rest and turns into "Show less".
Compose ChatSource.Trigger and ChatSource.Preview for a custom chip or preview. Set enablePreview when the source has no title or description.
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
The Chat Source component uses these CSS classes:
.chat-source: Source root.chat-source__trigger, .chat-source__trigger-link: Link or document chip.chat-source__icon: Favicon or custom logo.chat-source__icon-fallback: First-letter fallback.chat-source__document-icon: Document icon.chat-source__title: Chip label.chat-source__preview: Hover preview.chat-source__preview-link: Default preview link.chat-source__preview-header: Logo and domain row of the preview.chat-source__preview-domain: Domain in the preview header.chat-source__preview-title: Preview title.chat-source__preview-description: Preview description.chat-sources: Grouped source disclosure.chat-sources__trigger: Group trigger.chat-sources__trigger-label: Trigger content before the chevron.chat-sources__indicator: Trigger chevron.chat-sources__content: Collapsible panel.chat-sources__content-body: Panel padding.chat-sources__list: Wrapping source list.chat-sources__toggle: "+N more" / "Show less" chip[data-source-type="url|document"] on .chat-source: Source typeRenders a span. A source with href is a link, with a hover preview when it has a title or description. A source without href is a document. The chip renders only inline elements, so it can sit inside a paragraph. Supports native span props.
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | - | URL the chip links to |
title | string | domain of href | Label of the chip |
description | string | - | Text shown in the hover preview |
faviconUrl | string | - | Logo in the chip and the preview; falls back to the first letter |
sourceType | "url" | "document" | "url" when href is set | Link or file |
enablePreview | boolean | true with a title or description | Mounts the hover preview for URL sources |
children | ReactNode | trigger and preview | Custom composition |
The chip: an a for a URL source, or a span for a document. Link chips open in a new tab with rel="noopener noreferrer"; document chips are plain text. className, ref, and native props go to the chip, and children replace the default icon and title. Extends native a props.
A bare 16px logo. Draw monochrome SVG logos with currentColor, so they follow the label color in both themes.
| Prop | Type | Default | Description |
|---|---|---|---|
faviconUrl | string | source favicon | Overrides the source's faviconUrl |
children | ReactNode | first letter | Custom logo element; it receives the icon class on its root |
The chip label: title, or the domain of href. Supports native span props.
Hover preview content. Extends Hover Card HoverCard.Content props.
| Prop | Type | Default | Description |
|---|---|---|---|
title | ReactNode | source title | Overrides the source's title |
description | ReactNode | source description | Overrides the source's description |
Extends HeroUI Disclosure props.
A button inside a heading, with aria-expanded. Extends HeroUI Disclosure.Trigger props.
Extends HeroUI Disclosure.Content props.
Supports native div props. The "+N more" chip is a button with aria-expanded. Toggling the list keeps the visible chips mounted, so focus and open previews stay.
| Prop | Type | Default | Description |
|---|---|---|---|
maxVisible | number | - | Shows this many sources, then a "+N more" chip |
defaultShowAll | boolean | false | Whether every source shows at first |
showAll | boolean | - | Whether every source shows (controlled) |
onShowAllChange | (showAll: boolean) => void | - | Called when the chip toggles the list |
renderToggle | (state: {hiddenCount: number; showAll: boolean}) => ReactNode | "+N more" / "Show less" | Label of the chip |
These props only show or hide the extra sources. The ChatSources panel opens and closes with its own isExpanded, defaultExpanded, and onExpandedChange. maxVisible is rounded down, and values below 0 count as 0.
| Default text | Where | Override |
|---|---|---|
| "+N more" | ChatSources.List toggle chip while sources are hidden | renderToggle receiving {hiddenCount, showAll} |
| "Show less" | ChatSources.List toggle chip while every source shows | renderToggle receiving {hiddenCount, showAll} |
| "+2 more sources" (announced) | Accessible name of the toggle chip; "sources" is visually hidden | renderToggle; its label becomes the accessible name |
| "Source" | ChatSource.Title when the source has no title or href | title |
The renderToggle label is also the chip's accessible name, so mention the sources, for example ${hiddenCount} weitere Quellen.
<ChatSources.List
maxVisible={3}
renderToggle={({hiddenCount, showAll}) =>
showAll ? "Weniger anzeigen" : `${hiddenCount} weitere Quellen`
}
>
{sources}
</ChatSources.List>| API | Use instead |
|---|---|
ChatSource.Trigger label | children |
label still renders when the trigger has no children. See v1.0.0 for the full migration.
rel="noopener noreferrer". Document chips are plain text.ChatSources trigger is a button inside a heading, with aria-expanded.aria-expanded. Its accessible name starts with the visible text, so voice control can match it: "+2 more sources", where "sources" is visually hidden.Resources