Message Bubble
MessageBubble aligns user messages to the end and assistant/system messages to the start. Role styling, status dots, and optional metadata stay readable in both light and dark themes.
MessageBubble ships with a full API table, a copyable example, and accessibility notes.
Installation
Install the package once, then import MessageBubble from its direct entry point or from the root.
pnpm add @agent-ui/reactimport { MessageBubble } from "@agent-ui/react/message-bubble";Tailwind CSS v4 users: add @source "../node_modules/@agent-ui/react/src" to the global stylesheet so the library utilities are generated.
Usage
The example below is the same code that renders the preview. Copy it, swap in your own handlers, and ship.
import { MessageBubble } from "@agent-ui/react"; <MessageBubble role="user" name="You">Hello!</MessageBubble><MessageBubble role="assistant" name="Assistant" status="sent"> How can I help?</MessageBubble>API reference
Every prop MessageBubble accepts, its type, default, and behaviour.
| Name | Type | Default | Description |
|---|---|---|---|
| role | "user" | "assistant" | "system" | — | Controls alignment, color, and the screen-reader label. |
| children | ReactNode | — | Message content, usually text or MarkdownContent. |
| avatar | string | — | Avatar image URL. |
| name | string | — | Display name shown above the bubble. |
| timestamp | Date | — | Formatted time next to the name. |
| status | "sending" | "sent" | "error" | — | Delivery indicator. |
| className | string | — | Inherits every native div attribute, including id, aria-*, data-*, onClick, and style. |
Accessibility
MessageBubble composes with MessageList, ChatShell, useChat, and the provider compose blocks. Browse the full reference or see all components in the gallery.
6 lines · copy-ready