Skip to content
Haze UI

AI attachment reader

Chat column animating a PDF upload ring into a compact 6-page scan strip with clickable inline page citations and extracted excerpts.

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

When to use

  • Visualizing PDF upload progress followed by page-by-page document indexing inside an AI chat flow
  • Linking inline page citations directly to extracted document excerpts and an interactive page strip

When not to use

  • Extracting structured key-value fields into an editable form table; use document-extract instead
  • Citing external web URLs rather than pages of an uploaded file; use ai-citations

Installation

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

pnpm dlx shadcn@latest add @haze/ai-attachment
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-attachment"Unique prefix for section landmark heading ID.
headingstring"Document attachment exchange"Screen-reader landmark heading for the chat exchange.
fileNamestring"Q3-operations-brief.pdf"Filename displayed on the right-aligned PDF attachment card.
fileSizeMbnumber4.2Total file size in megabytes used for the live upload progress readout.
questionstring"What changed this quarter? Keep it short."User prompt bubble paired beneath the attached document.
pages{ page: number; title: string; snippet: string }[]6 demo PDF pagesPage metadata and extracted excerpts linked to the page strip and citation pills.
classstring–Extra classes applied to the outer section.

Keyboard interactions

Tab
Move across the 6 document page pills, inline page citation pills and the Replay button
EnterSpace
Highlight a referenced page and show its excerpt, or replay the upload sequence

Accessibility

  • Circular upload ring is exposed via role="progressbar" with aria-valuemin, aria-valuemax and live aria-valuenow updates.
  • Every page pill and inline page citation is a button with aria-pressed state that updates the extracted excerpt and announces changes politely.

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 attachment reader" with `npx shadcn@latest add @haze/ai-attachment`. 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 AiAttachment from "@/components/haze/blocks/ai-attachment.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-attachment.md

  • Customize with real content

    Adapt the Haze ai-attachment block for our product. Replace the demo values of these props with our real content: id, heading, fileName, fileSizeMb, question, pages, class. Keep the layout, the heading level rules and these accessibility details: Circular upload ring is exposed via role="progressbar" with aria-valuemin, aria-valuemax and live aria-valuenow updates. Every page pill and inline page citation is a button with aria-pressed state that updates the extracted excerpt and announces changes politely. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using ai-attachment, check it fits: use it when visualizing pdf upload progress followed by page-by-page document indexing inside an ai chat flow; linking inline page citations directly to extracted document excerpts and an interactive page strip. Avoid it when extracting structured key-value fields into an editable form table; use document-extract instead; citing external web urls rather than pages of an uploaded file; use ai-citations. Alternatives: @haze/document-extract, @haze/ai-citations, @haze/file-upload.

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