Skip to content

AI Answer

A streamed answer that shows its work: what the assistant searched, the sources it read, numbered citations that preview their source, and copy, regenerate, feedback and follow-ups.

On this page
Used for
  • Streamed answer card
  • Cited search reply
  • Answer with sources
  • Collect thumbs feedback
  • Offer follow-up questions

Examples

Installation

npx knowns-ui@latest add ai-answer
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Answer text

Paragraphs
blank line
A blank line starts a new paragraph.
Lists
"- " at line start
Consecutive lines become one list.
Bold, code
**bold** · `code`
Unclosed markers while streaming are fine - they run to the end.
Citations
[1] · [1, 3]
1-based indexes into sources. A citation still being typed is hidden until it closes.

Props

text
string
The answer. May grow while streaming; a text that no longer continues the old one starts over.
status
"thinking" | "streaming" | "done" | "stopped" | "error"
Default"done"
Thinking shows placeholders and “Reading N sources”; streaming keeps the caret going.
sources
AnswerSource[]
Default[]
{ title, site, url?, icon?, excerpt? }. Three fit the row, the rest fold into “+N more”.
steps
AnswerStep[]
{ label, state } - what the assistant did. Collapsed to one line, expandable.
question
string
Title above everything.
suggestions / onSuggestion
string[] / (q) => void
Follow-up questions shown once the answer is complete.
onRegenerate / onStop / onCopy
callbacks
Regenerate and copy after the answer; Stop while it is thinking or streaming.
onFeedback
(rating, reason?) => void
Good, or bad with one of feedbackReasons.
reveal / wordsPerSecond
boolean / number
Defaulttrue / 42
Smooth word-by-word reveal; off under reduced motion.
card
boolean
Defaulttrue
On its own card, or blended into the surrounding thread.
meta
ReactNode
Small text at the end of the action row, e.g. “Answered in 3.4s”.

Accessibility

The answer is marked aria-busy while it streams, so screen readers read it once. Citations are buttons named after their source; their preview is a tooltip that also opens on focus and closes with Escape. Copy and feedback are announced in a polite live region. With reduced motion the text appears at once.

What it handles

  1. 01Renders the text prop as paragraphs, dash lists, bold, inline code and numbered citations like [1] or [1, 3] that point at your sources.
  2. 02Reveals words at wordsPerSecond, 42 by default, and copes with half-streamed text by hiding an unfinished citation and closing an open bold or code span.
  3. 03Shows a preview card with the title, site and snippet when you hover or focus a citation, and Escape closes it.
  4. 04Moves through thinking, streaming, done, stopped and error through status, with a skeleton while thinking and a Stop button when you pass onStop.
  5. 05Lists what the assistant did as a collapsible steps list, and shows source pills before the text.
  6. 06Ends with Copy, Regenerate and thumbs, where a thumbs down asks "What was wrong?" with your feedbackReasons, and then follow-up suggestions.

States

First render
Nothing. A finished answer paints whole
none
Each new word
It fades in as it streams
280ms, ease out
Actions and reasons appear
The row rises into place
180ms, ease out
Citation preview opens
The card rises under the citation
120ms, ease out
Steps fold
The chevron turns a quarter turn
180ms, ease out
Skeleton and cursor
They pulse while the answer waits
none
Reduced motion
Text appears whole, with no word fade
0ms

Works with

When to use

When to use

  • Rendering a model's reply with sources, numbered citations that preview their source, and copy, regenerate and feedback actions.
  • Search-style answers where users need to check where a claim came from.

When not to use

  • The agent's steps before it answers: use Thinking State.
  • A whole chat screen with sidebar and composer: use Chat App.
  • Short system messages or errors: a plain message or a toast reads better: use Toast.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI AI Answer to my app and wire it to my own data.
  • I need rendering a model's reply with sources, numbered citations that preview their source, and copy, regenerate and feedback actions. Set that up with the Knowns UI AI Answer.
  • Which AI Answer props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "ai-answer" }) and search_docs({ query: "ai answer" }).

Need help?

Stuck on AI Answer, or found something off? We read every message.