Chat Message
A message row with avatar, header, body, footer slot and persistent actions in normal document flow.
A single chat message row: avatar, header (name + badges + timestamp), children body, optional reasoning/tool footer, and optional actions. Actions render in normal document flow below the body so they remain discoverable without hover. The component is presentational: role (user / assistant / system) selects default avatar/name, and the host supplies all other content. Pass plain text or a MarkdownRenderer from @yuhuanowo/yunui/content.
Import
import { ChatMessage } from "@yuhuanowo/yunui/chat";Example
The assistant row carries a model badge and Copy / Regenerate action slots. Actions stay in normal document flow below the message so touch, keyboard and pointer users can all discover them.
ChatMessage
How do I render markdown inside a message?
Feed the body as children — plain text, or a rendered markdown component from the content subpath.
Markdown bodies
Pair it with @yuhuanowo/yunui/content to render a full markdown message body:
import { ChatMessage } from "@yuhuanowo/yunui/chat";import { MarkdownRenderer } from "@yuhuanowo/yunui/content";
<ChatMessage role="assistant" name="Assistant" badges={<Badge>gpt-4o</Badge>}> <MarkdownRenderer content={message.content} /></ChatMessage>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| actions | ReactNode | — | Actions in normal flow below the content (copy, regenerate, …). |
| avatar | ReactNode | — | Avatar node. Defaults to a role icon in a themed circle. |
| badges | ReactNode | — | Inline chips next to the name (model, latency, mode, …). |
| children | ReactNode | — | The message body (plain text, or a rendered <MarkdownRenderer/>). |
| className | string | — | |
| density | "compact" | "comfortable" | comfortable | Vertical rhythm for dense transcripts and more spacious assistants. |
| footer | ReactNode | — | Extra content below the body — reasoning steps, tool details, JSON, … |
| name | ReactNode | — | Display name in the header. Defaults to a role label. |
| role* | "user" | "assistant" | "system" | — | Who sent the message. Drives the default avatar and name. |
| timestamp | ReactNode | — | Right-aligned timestamp (or any node) in the header. |