Answer
Present a cited AI answer with structured content, expandable sources, streaming reveal, version paging, and quiet actions.
import { Answer } from '@uthereal/ui/answer'Answer playground
How do we roll out passkeys without locking anyone out?
Enrollment alone hides password fallbacks and recovery friction. Stage the rollout additively with conditional autofill and track sign-in completion outcomes.
Add passkeys next to your current sign-in instead of replacing it. Offer enrollment right after a verified sign-in, and let browsers surface passkeys through conditional autofill so people never have to learn a new button. 13
Synced vs. device-bound
Passkeys are WebAuthn credentials that ship in two models. 2
| Synced | Device-bound | |
|---|---|---|
| Stored in | Platform account or password manager | One hardware key or device |
| Lost device | Restores automatically | Requires a backup key |
| Best for | Customer and team accounts | Admins and high-risk roles |
if (await PublicKeyCredential.isConditionalMediationAvailable?.()) {
const cred = await navigator.credentials.get({
mediation: "conditional",
publicKey: { challenge, rpId: "example.com" },
})
await verifyOnServer(cred)
}
Overview
Answer formats a single AI response as a readable article. It pairs an optional collapsible reasoning summary and expandable source cards with rich structured or markdown content: headings, lists, comparison tables, syntax-highlighted code blocks with copy, callouts, and inline [n] citations. Hovering or focusing a citation opens a source preview card and softly illuminates both the supporting sentence and its matching source card.
Use Answer whenever one question receives a formatted, cited response. Answer intentionally omits the prompt textbox and model picker so your layout can compose them independently. For an isolated pending state before text arrives, use Thinking indicator. For standalone action toolbars on chat turns, use Message actions.
Usage
'use client'
import { Answer } from '@uthereal/ui/answer'
export function PasskeyAnswer({
onFollowUp,
}: {
onFollowUp: (question: string) => void
}) {
return (
<Answer
question="What should we measure before each rollout stage?"
reasoning="Enrollment alone hides password fallbacks and recovery friction. Track completion outcomes and set explicit stage gates."
sources={[
{
id: 'webdev',
title: 'Sign in with a passkey through form autofill',
site: 'web.dev',
domain: 'web.dev',
url: 'https://web.dev/articles/passkey-form-autofill',
date: 'Sep 24, 2026',
snippet:
'Conditional mediation lists passkeys in the browser autofill menu next to saved passwords.',
},
{
id: 'mdn',
title: 'Web Authentication API',
site: 'MDN Web Docs',
domain: 'developer.mozilla.org',
url: 'https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API',
},
]}
blocks={[
{
kind: 'paragraph',
text: 'Measure whether people get in, not only whether they enroll. [1]',
},
{
kind: 'table',
columns: ['Signal', 'What it measures', 'Target trend'],
rows: [
[
'Passkey success',
'Completed WebAuthn sign-ins [2]',
'Above password rate',
],
['Fallbacks', 'Passkey offered, password used', 'Falling'],
],
},
]}
usage={{
model: 'Assistant',
tokens: 420,
thoughtSeconds: 6,
seconds: 3.1,
}}
followUps={['How should account recovery work?']}
onFollowUp={onFollowUp}
/>
)
}Pass either structured blocks or a markdown content string with [n] citation markers. Your application owns streaming, retries, share URLs, and follow-up navigation through callbacks (onRetry, onShare, onFollowUp, onFeedbackSubmit) or host-registered onAction names.
Examples
Structured blocks and open source cards
Pass structured blocks (paragraphs, tables, and callouts) with defaultSourcesOpen to show verified source cards alongside the answer. Use the playground above to test < 1 / N > version paging.
What should we measure before each passkey rollout stage?
Enrollment count alone hides password fallbacks and recovery friction. Pair sign-in completion metrics with explicit stage gates.
Thinking, stopped, and error states
Drive lifecycle states declaratively through status. thinking shimmers the reasoning row; stopped and error display an inline recovery banner with a Try again button when retryAction or onRetry is provided.
Why did checkout latency spike in eu-west-1?
Comparing regional p95 traces against the 14:20 deploy and database connection pool metrics.
Draft the Q3 incident postmortem
Checkout conversion dropped 9.2% on Safari after PR #4812 refactored address autofill listeners. 1
Compare monthly retention across cohorts
Content formats and citations
Answer accepts two interchangeable content inputs:
| Input | Supported elements |
|---|---|
blocks | paragraph, heading (h2–h4), list (ordered), table, code, and callout tones. |
content | Markdown headings, ordered and unordered lists, pipe tables, fenced code, and blockquotes. |
Inline text in both formats supports **bold**, *italic*, `code`, [label](url) links (validated to http(s), mailto, or relative paths), and [n] citations. Citation [1] maps to sources[0]. When sources is shown, wide containers arrange source cards in a two-column grid and narrow containers switch to a snap-scrolling horizontal row that scrolls newly highlighted cards into view.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
question | string— | Optional heading rendered above the answer; omit to display the answer body directly. |
content | string— | Markdown body supporting headings, lists, pipe tables, fenced code blocks, blockquotes, inline links, and [n] citations. |
blocks | AnswerBlock[]— | Structured content blocks (paragraph, heading, list, table, code, callout). Takes precedence over content when provided. |
sources | AnswerSource[]Default: [] | Cited sources numbered in order so [1] references the first entry; arrays replace on edit. |
reasoning | string— | Optional reasoning summary shown inside the collapsible Thought disclosure row. |
status | thinking | streaming | complete | stopped | errorDefault: "complete" | Authoritative answer lifecycle status supplied by the host: thinking, streaming, complete, stopped, or error. |
error | string— | Error explanation displayed inside the recovery banner when status is error. |
usage | AnswerUsage— | Quiet metadata line reporting model name, token count, thinking time, and total seconds. |
versions | AnswerVersion[]— | Multiple answer versions enabling the < 1 / N > version switcher in the footer. |
defaultVersion | integerDefault: 0 | Initial zero-based version index when versions is supplied; edits do not reset a mounted instance. |
followUps | string[]Default: [] | Clickable related follow-up questions displayed beneath the answer. |
showSources | booleanDefault: true | Show the collapsible sources row and expandable source cards when sources are present. |
defaultSourcesOpen | booleanDefault: false | Initial expanded state of the source cards panel; edits do not reset a mounted instance. |
showFooter | booleanDefault: true | Show the footer toolbar and usage metadata line once the answer settles. |
showCopy | booleanDefault: true | Show the Copy answer button in the footer toolbar. |
showShare | booleanDefault: false | Show the Copy share link button in the footer toolbar. |
showFeedback | booleanDefault: true | Show thumbs up and thumbs down feedback controls in the footer toolbar. |
feedbackReasons | string[]Default: ["Not accurate","Out of date","Missing a source","Too long","Did not answer the question"] | Reason chips presented inside the thumbs-down feedback popover. |
retryAction | string— | Registered host action requested when the user clicks Try again. |
shareAction | string— | Registered host action requested when the user clicks Share. |
followUpAction | string— | Registered host action requested with the clicked follow-up question. |
feedbackAction | string— | Registered host action requested when feedback is submitted or cleared. |
locale | string— | BCP 47 locale for token and duration formatting; inherited when omitted. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | AnswerThemeDefault: {} | Color mode, accent, and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | AnswerMotionOptionsDefault: {} | Disclosure, source stagger, and streaming chunk timing overrides in milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
AnswerSource accepts { id, title, site, domain, url?, date?, snippet?, color? }. AnswerUsage accepts { model?, tokens?, thoughtSeconds?, seconds? }.
React integration
| Prop | Purpose |
|---|---|
version | Controlled zero-based index into versions. |
onVersionChange(index) | Called when paging versions, in controlled and uncontrolled modes. |
onAction(action, payload) | Called for retryAction, shareAction, followUpAction, and feedbackAction. |
onFollowUp(question) | Called when a related follow-up question button is clicked. |
onShare() | Returns the URL string (or promise) copied by the Share toolbar button. |
onRetry() | Called when Try again is clicked in the footer or recovery banner. |
onFeedbackSubmit(event) | Called with { value, reason?, version, answer } on thumbs up, down, or clear. |
onCopyResult(copied) | Called after attempting to copy the answer with cited sources. |
onSourceSelect(source, index) | Called when clicking an inline [n] citation or source card; renders buttons instead of target="_blank" links so hosts can open an in-app viewer. |
renderSourceIcon(source, ctx) | Custom decorative site mark renderer; defaults to a deterministic domain letter. |
highlight(code, language) | Custom line-based syntax highlighter replacing the built-in regex highlighter. |
portalContainer | Target container for portalled citation hover cards, tooltips, and popovers. |
preset | Application defaults overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root. |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Moves across reasoning and sources disclosures, source cards, citations, tables, code, actions, and follow-ups. |
Enter, Space | Toggles reasoning or sources disclosures, activates actions, or opens a focused citation link. |
Escape | Closes an open citation hover card or thumbs-down feedback popover and returns focus. |
The root renders a labelled <section> with aria-busy="true" while thinking or streaming. Two polite live regions announce lifecycle state changes and action results (copy, share, feedback, version changes). Closed disclosure panels set inert so hidden links leave the tab order. Comparison tables use scope="col" and scope="row" headers inside a focusable scroll region, and code blocks render inside a focusable <pre>. Reading direction inherits from the page or follows dir. Under forced-colors, cards, citations, tables, callouts, and focus outlines remain distinct.
Motion and theming
While status="thinking", the reasoning row runs a light shimmer that settles to solid text once finished. While status="streaming", an append-stable parser commits chunks on a requestAnimationFrame clock (default 34ms ticks, 160ms fade-in) without shifting settled lines, holding table rows and code lines until their newline arrives. Disclosure panels and version switches use smooth non-overshooting height springs, hovering the sources row fans the stacked marks apart, and version numerals roll in place. prefers-reduced-motion: reduce removes spatial travel, fans, fades, and springs while preserving chunked arrival; motion="none" makes every state transition immediate (0ms).
theme accepts a mode, an accent, and tokens for surfaces, borders, reading column width (maxWidth), code text size (codeSize), and syntax colors (syntaxString, syntaxNumber, syntaxKeyword, syntaxType, syntaxFunction, syntaxProperty, syntaxTag). An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, Answer is a leaf. The host stores the active version index at /components/instance-<id>/version, seeded from defaultVersion and clamped when versions changes. retryAction, shareAction, followUpAction, and feedbackAction must name registered host actions; configuration edits never run network work or stream automatically. See Building with agents.
{
"type": "Answer",
"props": {
"question": "How do we roll out passkeys safely?",
"content": "Add passkeys next to existing sign-in and surface them via conditional autofill. [1]",
"sources": [
{
"id": "webdev",
"title": "Passkey form autofill",
"site": "web.dev",
"domain": "web.dev",
"url": "https://web.dev/articles/passkey-form-autofill"
}
],
"followUpAction": "ask_follow_up",
"followUps": ["How should account recovery work?"]
},
"children": []
}