ChatMessage
Renders one message and its ordered parts — markdown text via StreamingMarkdown, reasoning, tool-call status, attachment chips, and a deduplicated citation footer — with a hover-revealed copy/regenerate bar and an error/aborted alert. bubble tints and aligns per role; plain is a document-like full-width column.
One message rendered on its own. Flip the layout between the tinted bubble and the document-like plain column, change the role to see the per-role tint
and alignment, and hover the message to reveal the copy / regenerate bar. For the whole
conversation in motion, open the live playground.
01 Examples
An agentic message
Custom tool-call renderer
Error state with retry
Retry pressed 0×
02 Part dispatch
A message is an ordered list of parts. ChatMessage walks
them in order and picks a renderer per type — this is what
lets a single component present a plain answer and a full agentic transcript alike.
text→ rendered through StreamingMarkdown (never{@html}; every link is URL-policy checked).reasoning→ a collapsed ReasoningDisclosure with a "Thought for Xs" label.tool-call→ a ToolCallCard reflecting its pending / running / complete / error state.attachment→ a policy-checked chip; the URL is only ever a download link, never inline media.source→ collected out of the flow into the deduplicated citation footer (and feeds the[n]markers).
Override any part type except source via partRenderers, and swap the avatar, action bar or
metadata row through their respective snippets. The component never mutates the message it is
handed.
03 Accessibility
Labelled actions
The copy and regenerate buttons carry aria-labels (copyLabel, regenerateLabel) and are wrapped in tooltips. They
live in a bar revealed on hover / focus-within, so keyboard users reach them by
tabbing — the reveal is presentational, not a focus trap.
Copy feedback
A successful copy is announced through a visually hidden role="status" region (the copiedLabel text), so screen-reader users hear the confirmation
without a visible toast.
Error & aborted alerts
status: 'error' and 'aborted' render through the Alert primitive, so the failure is exposed with the correct alert semantics rather than styled text
alone.
Decorative avatar & time
The role avatar is decorative and hidden from assistive tech; the timestamp renders as a
semantic <time datetime> element so the machine-readable
instant travels with the visible label.
04 API Reference
No matching properties |