AI response
An AI response with a state for everything that happens: nothing drawn for a fast start, then thinking, each tool call as a step with its arguments one click away, text revealed at an even pace instead of in bursts, citations that only link when a source is behind them, a 'still working' with Stop when nothing arrives, and Retry that keeps what came. Screen readers hear the finished answer once, not every token. The demo replays real runs from a local model at their recorded pace, including a tool timing out and the model reading the wrong component.
- Streaming
- Tool calls
- aria-live
- Latency states
- Recorded replay
Ask
Usage
Drop it in
import { AIResponse } from "@/app/lib/components/ai-response";const a = useAssistant();
<AIResponse {...a} onStop={a.stop} onRetry={() => a.start(source)} />API
Props
| Prop | Type | Default |
|---|---|---|
phase*Where the response is, from `useAssistant`. | AssistantPhase | — |
text*Everything that has arrived so far. | string | — |
steps*Tool calls in the order they were made. | ToolStep[] | — |
sources*Sources the tools returned. Only the ones the text cites are listed. | Source[] | — |
stalledSSeconds since anything arrived, once that is past the slow threshold; 0 otherwise. | number | 0 |
errorShown when the response fails. | string | — |
onStop | () => void | — |
onRetry | () => void | — |
nameWho is answering. Default: "Assistant" | string | "Assistant" |
className | string | "" |
Read from the component's source at build time. * required.
Accessibility
Works with
- Cursor
- Reacts to where the pointer is, not just whether it's over the element.
- Touch
- Follows your finger while it's down, then settles a moment after you lift.
- Keyboard
- Focus lights it up the way the cursor does. Every action has a key.
- Reduced motion
- Nothing moves or springs. Colour still answers, without drifting.