Overview
TheChatMessage component renders individual chat messages with rich content support. It handles both user and agent messages, displays markdown with syntax highlighting using Streamdown, supports mermaid diagrams, and can show tool call information. The component intelligently handles message parts and applies appropriate styling based on the message role.
Props
The message object containing role, parts, and other message data. Uses the
UIMessage type from the AI SDK.Whether this is the last message from the bot/agent in the conversation. Used to apply special visual effects (glowing shadow) to highlight the latest response.
TypeScript Interface
UIMessage Structure
TheUIMessage type from the AI SDK includes:
Usage
Features
Rich Content Rendering
- Markdown Support: Full markdown rendering via Streamdown
- Code Syntax Highlighting: Uses
@streamdown/codeplugin with vitesse themes - Mermaid Diagrams: Renders mermaid diagrams with custom Dracula-inspired theme
- Tool Call Display: Shows tool invocations with name and output
Visual Styling
User Messages
- Aligned to the right (flex-row-reverse)
- User icon in a muted background circle
- Accent background color
- Rounded corners with top-right corner less rounded
- Border with zinc-400 color
Agent Messages
- Aligned to the left
- Bot icon in accent background circle
- Card background color
- Rounded corners with top-left corner less rounded
- Border with white/20 opacity
- Special Effect: Last bot message gets a glowing white shadow
Content Filtering
The component intelligently handles empty or tool-only messages:- Returns
nullif no renderable content exists - Checks for non-empty text parts
- Considers tool-related parts as renderable
Message Parts Handling
- Text Parts: Rendered with Streamdown markdown processor
- Tool Parts: Displayed in a gray muted box with:
- Tool name in monospace font
- JSON-formatted output (if available)
- Syntax highlighting for better readability
Streamdown Configuration
Code Plugin
Mermaid Plugin
Custom Dracula-inspired theme with:- Dark background (#282a36)
- Purple borders (#bd93f9)
- Cyan and pink accents
- White text (#f8f8f2)
- Yellow connector lines
Examples
Simple Text Message
Message with Code
Message with Tool Call
Related Components
ChatTypingIndicator
Shows when agent is processing
ChatInput
Input for creating new messages