Components/InlineCitation

InlineCitation

A source-reference chip set inside prose.

VerifiedSince 0.3.9

Usage

Basic

Loading demo...

Streaming Answer

A citation pops in as the prose reaches it; the host orchestrates the answer, and the component renders one chip.

Word reveal + inline citation + sources + follow-ups

Loading demo...

Best Practices

  • Listen for open, or clicking a citation does nothing.
  • Keep to two or three citations per paragraph; a dense run reads as a list.
  • Usually leave label empty: the hostname fallback shows where a claim came from.
  • Keep source.id stable in streaming surfaces, so a broken favicon isn't retried as nodes are reused.
  • Use TxSources for the source list at the end of an answer; both share AiSourceItem and often appear together.

API Reference

Props

NameTypeDefaultDescription
sourceAiSourceItem—The reference, { id, url, title?, favicon? }. Required.
labelstring—Chip text; falls back to source.title, then the www.-stripped hostname, then the raw url.
appearbooleantruePlays the entrance pop on mount; set false when re-rendering a settled answer.

Events

NamePayloadDescription
open(source: AiSourceItem)Fires on click; navigation is prevented and left to the host.

Slots

NameScopeDescription
default{ source, label }Replaces the chip text, rich content included.
icon{ source }Replaces the leading favicon.

Overview

  • It renders a real <a href>; a click calls preventDefault() and emits open, so it never navigates an Electron renderer away. The browser's "open in new tab" and "copy link address" still work.
  • A favicon that fails to load stops rendering, and the chip degrades to text.
  • The icon carries alt="" and aria-hidden; the accessible name comes from the chip text.
  • The chip sits in the text flow; line height belongs to the surrounding paragraph.
  • The entrance plays once, on mount; flipping appear later replays nothing.

Technologies

  • Adapted from Beautiful UI (© 2026 Shane Levine, MIT).
  • Source: packages/tuffex/packages/components/src/inline-citation/.
查看源码
packages/tuffex/packages/components/src/inline-citation/index.ts