Message
Displays a message in a conversation, with optional avatar, header, footer, and alignment.
Installation
Command to install the Message component.
Component Guide
Use the following to build the Message component.
from components.ui.message import messageSource Code & Dependencies
For manual installation, copy each of the source codes below in their respective locations.
components/core/core.py
components/ui/message.py
The Message component lays out a single message in a conversation. It handles the avatar, alignment, header, and footer around the message surface.
For AI apps, you can render reasoning steps, tool calls and assistant messages using the Message component.
Examples
Avatar
Use message.avatar to render an avatar next to the message. Set align="end" on the message to align the avatar to the end of the message.
Props used: align on message.root.
Group
Use message.group to stack consecutive messages from the same sender. Render an empty message.avatar on the earlier messages to keep them aligned with the avatar on the last one.
Props used: none required beyond default message.group composition.
Header and Footer
Use message.header for a sender name and message.footer for metadata such as a delivery or read status.
Props used: none required beyond default message.header/message.footer composition.
Actions
Place message-level actions in message.footer, such as copy, retry, or feedback buttons.
Props used: none required — place button(...) inside message.footer.
Attachment
Use the Attachment with the messages to displays a file or image attachment with media, metadata, upload state, and actions.
Props used: see the Attachment docs for attachment-specific props.
Accessibility
Message is a presentational layout wrapper. Accessibility comes from the content you place inside it.
Label icon-only actions
Action buttons in message.footer are usually icon-only, so give each one an aria-label.
message.footer(
button(
hi("Refresh03Icon"),
variant="ghost",
size="sm",
title="Retry",
aria_label="Retry",
),
)
Status updates
For in-progress messages, use a Marker with role="status" so assistive tech announces the update as it appears.
message.root(
message.content(
marker.root(
marker.icon(spinner()),
marker.content("Compacting conversation"),
role="status",
),
),
)
API Reference
message.root
The message row wrapper.
message.group
Groups consecutive messages from the same sender.
message.avatar
The avatar slot, aligned to the bottom of the message. When the message has a message.footer, the avatar shifts up to stay aligned with the message surface instead of the footer.
message.content
Wraps the header, message surface, and footer.
message.header
Displays content above the message, such as a sender name. Stays aligned to the start regardless of align.
message.footer
Displays content below the message, such as status or actions. Aligns to the message side.