AI Interface Components

AI Source Citations

Inline citation markers in an AI answer, with a source preview card that floats out on hover.

This is a WebberUI Pro component

The install command below needs a licence to run; without one it returns 401.

How to install Pro components →See the plans →

Superscript [1][2] citation markers embedded in an AI answer's paragraph: hovering or clicking one floats out a source preview card (favicon color swatch, title, snippet, and domain link), and the source list at the bottom highlights in both directions with the markers — a good fit for RAG Q&A, AI search, and anywhere the basis for an answer needs to be shown.

Bring this into your project

Run this command in your project folder. The CLI adds the source and dependencies; then follow the usage example below.

npx webberui@latest add "https://webberui.com/r/ai-source-citations.en.json?t=<install token>"

New project or installation trouble? Start here →

Playground

Tune the props live — the code snippet updates as you go, so you can dial in the look you want before copying it.

Active edited usageDefault props
<AiSourceCitations/>

The complete example includes the preview layout and data. Install the component first, then paste this file into your project.

Installation

npx webberui@latest add "https://webberui.com/r/ai-source-citations.en.json?t=<install token>"

Or, once registries are configured in components.json, install it as @webberui/ai-source-citations.

Usage

import { AiSourceCitations } from "@/components/ui/ai-source-citations";

<AiSourceCitations
  segments={[
    { text: "RAG has the model retrieve external knowledge before it answers", citations: [0] },
    { text: ", which effectively reduces hallucination and supplies the basis.", citations: [1] },
  ]}
  sources={[
    {
      title: "What is Retrieval-Augmented Generation?",
      domain: "aws.amazon.com",
      snippet: "Having the model consult an authoritative external knowledge base before generating a response…",
      url: "https://aws.amazon.com/what-is/retrieval-augmented-generation/",
    },
    {
      title: "A practical guide to RAG",
      domain: "ithome.com.tw",
      snippet: "Retrieving relevant document fragments from a vector database and then synthesizing an answer…",
    },
  ]}
/>

Props

PropTypeDefaultDescription
segmentsCitationSegment[]—List of answer segments, rendered in order into a single paragraph
segments[].textstring—The answer text of this segment
segments[].citationsnumber[]—The sources to mark after this segment's text (0-based indices into sources)
sourcesCitationSource[]—List of cited sources; the array order is the marker number (starting at 1)
sources[].titlestring—Source title, shown in the preview card and the bottom list
sources[].domainstring—Source domain, used for the favicon swatch letter and the domain row
sources[].snippetstring—Snippet of the source content, shown in the hover preview card (up to two lines)
sources[].urlstring—Optional link; when provided, the preview card's domain row and the list item become clickable
showSourceListbooleantrueWhether the source list at the bottom is shown (highlighting in sync with the inline markers)
classNamestring—Forwarded to the outermost container, merged through cn()

Accessibility

  • Citation markers are native <button> elements, focusable with Tab; focusing one opens the preview card, and Escape closes it
  • Markers carry aria-expanded and a complete aria-label (including the number and the source title), and the preview card is role="tooltip"
  • It only closes once focus leaves both the marker and the card, so keyboard users can Tab into the source link inside the card
  • When "reduce motion" is enabled at the system level, the preview card only fades in and out, with no shift or scale animation
  • Decorative elements like the favicon swatch and the small arrow are all marked aria-hidden and do not interfere with announcement