Docs
Chat Message
Chat Message
A customizable message bubble component for chat interfaces with support for user and AI messages.
The ChatMessage component provides a styled message bubble with support for markdown content, timestamps, animations, and contextual actions.
Installation
Usage
Props
Prop | Type | Default | Description |
---|---|---|---|
role | "user" | "assistant" | string | Required | The role of the message sender |
content | string | Required | The message content (supports markdown) |
createdAt | Date | - | Timestamp for the message |
showTimeStamp | boolean | false | Whether to show the timestamp |
animation | "none" | "slide" | "scale" | "fade" | "scale" | Animation style for the message bubble |
actions | ReactNode | - | Actions to show on hover (assistant only) |
id | string | Required | Unique identifier for the message |
attachments | File[] | - | Array of attached files |
Examples
Different Animation Styles
With Actions
With Timestamp
Styling
The component uses CSS variables for theming and can be customized using the following classes:
group/message
: The message containertext-primary-foreground
: User message text colortext-foreground
: Assistant message text colorbg-primary
: User message backgroundbg-muted
: Assistant message background
Custom Styling
Accessibility
- Messages are properly structured for screen readers
- Timestamps use semantic HTML
- Actions are keyboard accessible
- Color contrast meets WCAG guidelines
Design Considerations
- Messages from different roles (user/assistant) are visually distinct through color and positioning
- Animations can be disabled for reduced motion preferences
- Actions are only shown on hover for a cleaner interface
- Markdown support allows for rich content formatting
- Timestamps are optional and format according to the user's locale