Message Container
Container component for individual conversation messages
The MessageContainer component wraps individual conversation messages, displaying the message role and content in a structured format. It's typically used within the Conversation component to render each message in the conversation history.
import { MessageContainer } from "@pipecat-ai/voice-ui-kit";
<MessageContainer
message={{
role: "assistant",
parts: [{ text: "Hello! How can I help you today?" }],
createdAt: new Date().toISOString()
}}
/>Component Variants
MessageContainer
The MessageContainer component displays a single message with its role and content.
import { MessageContainer } from "@pipecat-ai/voice-ui-kit";
<MessageContainer
message={{
role: "user",
parts: [{ text: "What's the weather like?" }],
createdAt: new Date().toISOString()
}}
/>| Prop | Type | Default |
|---|---|---|
message | ConversationMessage | - |
assistantLabel? | string | "assistant" |
clientLabel? | string | "user" |
systemLabel? | string | "system" |
classNames? | { container?: string; messageContent?: string; role?: string; thinking?: string; time?: string; } | {} |
Usage
Basic Usage
Display a message with default styling.
import { MessageContainer } from "@pipecat-ai/voice-ui-kit";
<MessageContainer
message={{
role: "assistant",
parts: [{ text: "Hello! How can I help you?" }],
createdAt: new Date().toISOString()
}}
/>Custom Labels
Customize the labels for different message roles.
import { MessageContainer } from "@pipecat-ai/voice-ui-kit";
<MessageContainer
message={{
role: "assistant",
parts: [{ text: "Hello!" }],
createdAt: new Date().toISOString()
}}
assistantLabel="AI Assistant"
clientLabel="You"
systemLabel="System"
/>Custom Styling
Apply custom classes to different parts of the message.
import { MessageContainer } from "@pipecat-ai/voice-ui-kit";
<MessageContainer
message={{
role: "user",
parts: [{ text: "Custom styled message" }],
createdAt: new Date().toISOString()
}}
classNames={{
container: "border rounded p-4 bg-muted",
role: "text-lg font-bold",
messageContent: "mt-2"
}}
/>Multiple Parts
Messages can contain multiple parts (text chunks).
import { MessageContainer } from "@pipecat-ai/voice-ui-kit";
<MessageContainer
message={{
role: "assistant",
parts: [
{ text: "First part. " },
{ text: "Second part. " },
{ text: "Third part." }
],
createdAt: new Date().toISOString()
}}
/>Message Structure
The component expects a ConversationMessage object with:
role: "user" | "assistant" | "system"parts: Array ofConversationMessagePartobjects, each with atextpropertycreatedAt: ISO timestamp string
Integration
The MessageContainer component uses:
MessageRolecomponent to display the role labelMessageContentcomponent to display the message content
It's typically used within the Conversation component to render individual messages from the conversation history.