YuhuanStudioYunUIDocs
Chat

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

tsx1 line
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

You9:41 AM

How do I render markdown inside a message?

Assistant
gpt-4o
9:41 AM

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:

tsx6 linesScroll horizontally
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

PropTypeDefaultDescription
actionsReactNode—Actions in normal flow below the content (copy, regenerate, …).
avatarReactNode—Avatar node. Defaults to a role icon in a themed circle.
badgesReactNode—Inline chips next to the name (model, latency, mode, …).
childrenReactNode—The message body (plain text, or a rendered <MarkdownRenderer/>).
classNamestring—
density"compact" | "comfortable"comfortableVertical rhythm for dense transcripts and more spacious assistants.
footerReactNode—Extra content below the body — reasoning steps, tool details, JSON, …
nameReactNode—Display name in the header. Defaults to a role label.
role*"user" | "assistant" | "system"—Who sent the message. Drives the default avatar and name.
timestampReactNode—Right-aligned timestamp (or any node) in the header.

On this page