AI chat
A thread with streaming replies, suggestions, stop and retry, and a composer.
ComponentsStreaming UI
Preview theme
Playground
Replies are canned and chosen by keyword, then streamed word by word. Stop cuts a reply short, and every fourth message fails on purpose so you can see the error and retry.
Preview
Demo data
Props
Density
Streaming speed
example.tsxtsx
1import { AiChat } from "@/components/ui/ai-chat"23<AiChat4 suggestions={["Which deals are at risk?", "List overdue invoices"]}5 stream={(prompt, { signal }) => streamReply(prompt, { signal })}6/>States
The composer at rest, focused and disabled, and an assistant reply while streaming, hovered, failed and rated.
States
- Default
rest - Hover
:hover → actions - Focus
:focus-visible - Loading
aria-busy - Disabled
disabled - Error
retry - Success
aria-pressed
Record side panel
Demo data
Acme Corporation
Renewal, closes Oct 30
- Stage
- Negotiation
- Value
- $48,000
- Owner
- LF Lena Fischer
Keyboard
- Send the message
- Enter
- New line
- Shift+Enter
- Reach Stop, suggestions and reply actions
- Tab
Semantics and ARIA
- The thread is a
role="log"witharia-busywhile streaming. Its own live updates are off, so tokens aren't read one by one. - A separate polite
role="status"region says when a reply starts, then reads the finished reply once. Stop and failures are announced too. - After sending, focus returns to the composer, including when a suggestion chip is used and removed. Stop moves focus back to the composer as well.
- Send is disabled while the composer is empty, and becomes a labelled
Stop generatingbutton while a reply streams. - Reply actions are icon buttons with labels and tooltips; the thumbs use
aria-pressed. They stay visible on touch screens. - Brand violet marks AI: the assistant avatar, streaming caret, send button and suggestion chips.