Skip to content
Haze UI

AI chat

Conversational AI workspace with thread switcher, collapsible reasoning, tool chips, source cards, feedback actions and stop control.

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

When to use

  • Building a full workspace assistant where replies include reasoning steps, tool calls and cited sources
  • Users need to switch between recent threads, pick a model and stop or regenerate answers

When not to use

  • You only need a single prompt input bar without a message history; use ai-composer instead
  • You want an editorial single-answer layout rather than a multi-turn chat; use ai-answer

Installation

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

pnpm dlx shadcn@latest add @haze/ai-chat
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-chat"Unique prefix for headings and form controls.
titlestring"Workspace assistant"Header title for the active chat workspace.
modelsstring[]3 demo modelsModel choices shown in the header selector.
threads{ id: string; title: string; updated: string }[]3 demo threadsSidebar conversation list.
messagesMessage[]2 demo messagesInitial conversation turns with optional reasoning, tools and sources.
placeholderstring"Ask a follow-up or reference a PR…"Composer textarea placeholder.
classstring–Extra classes on the outer section.

Keyboard interactions

Tab
Move across thread buttons, model select, reasoning disclosures, message actions and composer
EnterSpace
Toggle reasoning disclosure, rate a reply, switch threads or submit a message

Accessibility

  • Reasoning uses a native details disclosure so keyboard and screen-reader users can expand or collapse thinking steps without script.
  • Live status updates (thread switch, copy, feedback, streaming state) are announced through a polite role="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 chat" with `npx shadcn@latest add @haze/ai-chat`. 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 AiChat from "@/components/haze/blocks/ai-chat.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-chat.md

  • Customize with real content

    Adapt the Haze ai-chat block for our product. Replace the demo values of these props with our real content: id, title, models, threads, messages, placeholder, class. Keep the layout, the heading level rules and these accessibility details: Reasoning uses a native details disclosure so keyboard and screen-reader users can expand or collapse thinking steps without script. Live status updates (thread switch, copy, feedback, streaming state) are announced through a polite role="status" region. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using ai-chat, check it fits: use it when building a full workspace assistant where replies include reasoning steps, tool calls and cited sources; users need to switch between recent threads, pick a model and stop or regenerate answers. Avoid it when you only need a single prompt input bar without a message history; use ai-composer instead; you want an editorial single-answer layout rather than a multi-turn chat; use ai-answer. Alternatives: @haze/chat-thread, @haze/bento-assistant.

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