YuhuanStudioYunUIDocs
Chat

Chat Message

A single message row — avatar, header (name + badges + timestamp), body, footer slot and hover-revealed actions.

A single chat message row: an avatar, a header (name + badges + timestamp), the body passed as children, an optional footer slot for reasoning / tool details, and hover-revealed actions. It's fully presentational — the role (user / assistant / system) drives the default avatar and name, and every other part is a slot. Feed the body as plain text, or as a rendered MarkdownRenderer from @yuhuanowo/yunui/content.

Import

tsx
1import { ChatMessage } from "@yuhuanowo/yunui/chat";

Example

The assistant row carries a model badge and hover-revealed actions; hover it to reveal the Copy / Regenerate controls.

ChatMessage

You
9: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:

tsx
1import { ChatMessage } from "@yuhuanowo/yunui/chat";
2import { MarkdownRenderer } from "@yuhuanowo/yunui/content";
3 
4<ChatMessage role="assistant" name="Assistant" badges={<Badge>gpt-4o</Badge>}>
5 <MarkdownRenderer content={message.content} />
6</ChatMessage>

Props

PropTypeDefaultDescription
actionsReactNodeActions revealed on hover below the content (copy, regenerate, …).
avatarReactNodeAvatar node. Defaults to a role icon in a themed circle.
badgesReactNodeInline chips next to the name (model, latency, mode, …).
childrenReactNodeThe message body (plain text, or a rendered <MarkdownRenderer/>).
classNamestring
density"compact" | "comfortable"comfortableVertical rhythm for dense transcripts and more spacious assistants.
footerReactNodeExtra content below the body — reasoning steps, tool details, JSON, …
nameReactNodeDisplay name in the header. Defaults to a role label.
role*"user" | "assistant" | "system"Who sent the message. Drives the default avatar and name.
timestampReactNodeRight-aligned timestamp (or any node) in the header.

On this page