Response
The assistant's answer as a prose column, with a caret while tokens arrive and a skeleton before the first one.
You can keep the composer and the answer in the same column. Three things make it read well:
- Render markdown outside the component and pass the result as
children. - Keep code in a block with its own copy button.
- Show the caret only while tokens are still arriving.
const answer = await model.generate({
prompt: 'Summarise this thread',
maxTokens: 200,
});
Installation
pnpm dlx nachui add responseAnatomy
Response does not parse markdown. It styles whatever you render inside it: paragraphs, headings, lists, inline code and blockquotes get the spacing and type of an answer, and a CodeBlock drops in as is. Render the markdown with react-markdown or your own pipeline and pass the result as children, so the component stays dependency free and you keep control of the renderer.Composition
Use the following composition to build a
Response:Streaming
While
isStreaming is true, a caret blinks after the last node and the root carries aria-busy. Before the first token there is nothing to show, so render Response.Skeleton instead: three shimmering lines that read as an answer being written.Reading the question and what came before it
Pulling the parts of the answer together
Writing it down
API Reference
Response
| Prop | Type | Default | Description |
|---|---|---|---|
isStreaming | boolean | false | Shows the caret and sets aria-busy |
className | string | - | Additional CSS classes |
Response.Content
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
Response.Caret
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
Response.Skeleton
| Prop | Type | Default | Description |
|---|---|---|---|
lines | string[] | three placeholder lines | Text of each shimmering line |
className | string | - | Additional CSS classes |
Found something to improve?
Notice a bug, typo, or missing detail on this page? Help us make the documentation better by opening a GitHub issue.