Skip to content
Haze UI

AI inline citations

Borderless grounded AI prose with inline domain pills that highlight sentences, open a source preview card and toggle all sources.

pnpm dlx shadcn@latest add @haze/ai-citations
Open preview in a new tab
Livesmall script

When to use

  • Attributing individual claims in an AI summary to one or more verifiable web or document sources
  • Letting readers hover, focus or click inline domain pills to inspect backing excerpts without cluttering initial prose

When not to use

  • You need a full answer layout with thumbs feedback, version pagination and a follow-up bar; use ai-answer instead
  • Showing citations pinned to page numbers inside an uploaded PDF file; use ai-attachment

Installation

Add the Haze registry to components.json once, then install AI inline citations with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/ai-citations
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
idstring"haze-ai-citations"Unique prefix for landmark heading and source-list ARIA IDs.
headingstring"Grounded answer with inline citations"Screen-reader landmark heading for the cited prose section.
sources{ id: string; domain: string; title: string; excerpt: string; url: string }[]4 demo web sourcesReference items displayed in the hover/click preview card and expandable sources list.
claims{ text: string; sourceIds: string[] }[]4 cited claimsOrdered sentences mapped to one or more source IDs.
classstring–Extra classes applied to the outer section.

Keyboard interactions

Tab
Move across inline citation pills, preview controls and the sources toggle button
EnterSpace
Pin a citation preview card, switch paired sources or expand the full source list
Escape
Dismiss the active citation preview card and clear the sentence highlight

Accessibility

  • Inline citation pills and multi-source preview tabs are native buttons with aria-pressed state, hover/focus highlight and Escape dismissal.
  • The footer sources button uses aria-expanded and aria-controls to toggle the full reference list, announcing changes in a polite status region.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI block "AI inline citations" with `npx shadcn@latest add @haze/ai-citations`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import AiCitations from "@/components/haze/blocks/ai-citations.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/ai-citations.md

  • Customize with real content

    Adapt the Haze ai-citations block for our product. Replace the demo values of these props with our real content: id, heading, sources, claims, class. Keep the layout, the heading level rules and these accessibility details: Inline citation pills and multi-source preview tabs are native buttons with aria-pressed state, hover/focus highlight and Escape dismissal. The footer sources button uses aria-expanded and aria-controls to toggle the full reference list, announcing changes in a polite status region. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using ai-citations, check it fits: use it when attributing individual claims in an ai summary to one or more verifiable web or document sources; letting readers hover, focus or click inline domain pills to inspect backing excerpts without cluttering initial prose. Avoid it when you need a full answer layout with thumbs feedback, version pagination and a follow-up bar; use ai-answer instead; showing citations pinned to page numbers inside an uploaded pdf file; use ai-attachment. Alternatives: @haze/ai-answer, @haze/ai-attachment, @haze/hover-card.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog