A composable chat message bubble with avatar, content, and timestamp sub-components. Role-aware layout for user and assistant messages.
Installation
Usage
Used with Chat Container
MessageBubble is designed to be composed inside ChatContainerMessage:
How It Works
MessageBubbleaccepts aroleprop ("user"or"assistant") and provides it to all children via React Context.role="user"reverses the flex row so the avatar appears on the right;role="assistant"keeps it on the left.MessageBubbleAvatarautomatically picks aUserIconorBotIconfallback based on the role. Passsrcto use a custom image.MessageBubbleContentapplies different background and text colours per role —bg-primaryfor user,bg-mutedfor assistant — and rounds corners asymmetrically to create a tail effect.MessageBubbleTimestampaligns right and uses a reduced opacity colour matching the bubble's role.
API Reference
MessageBubble
| Prop | Type | Default |
|---|---|---|
role | "user" | "assistant" | - |
MessageBubbleAvatar
| Prop | Type | Default |
|---|---|---|
src? | string | - |
fallback? | string | - |
className? | string | - |
MessageBubbleContent
Accepts all div props. Applies role-aware bubble styling automatically.
MessageBubbleTimestamp
Accepts all p props. Renders below the message content with a muted role-aware colour.
useMessageBubble
Hook that exposes { isUser: boolean } from the bubble context. Must be used inside <MessageBubble />.