Skip to content

Message Bubble

The MessageBubble component displays conversational messages in AI and chat interfaces. It’s a compound component — MessageBubble.Root sets the message role, MessageBubble.Content holds the body, MessageBubble.Text / MessageBubble.Markdown render the message, and MessageBubble.Footer carries actions like copy, edit, and timestamps. User and assistant messages get distinct styling and alignment.

Installation

import {
MessageBubble,
CopyButton,
Button,
IconV2,
Text,
} from "@harnessio/ui/components";
// ...
return (
<MessageBubble.Root role="user">
<MessageBubble.Content>
<MessageBubble.Text>Your message here</MessageBubble.Text>
</MessageBubble.Content>
<MessageBubble.Footer>
<CopyButton name="Your message here" buttonVariant="ghost" size="sm" />
<Button iconOnly variant="ghost" size="sm" onClick={handleEdit}>
<IconV2 name="edit" />
</Button>
<Text variant="caption-normal" color="foreground-3">
{formatTime(timestamp)}
</Text>
</MessageBubble.Footer>
</MessageBubble.Root>
)