Skip to main content
The MessageItem component renders individual messages in a chat interface. It provides role-based styling (user vs assistant), markdown content rendering, and interactive copy functionality with smooth hover states.

Installation

Install the MessageItem component using the shadcn CLI:

Usage

Props

UIMessage
required
The message object to display. Uses the standard UI message format from AI SDK with parts array.
string
Additional CSS classes to apply to the message container.
React.CSSProperties
Inline styles to apply to the message container.
React.Ref<HTMLDivElement>
Reference to the message container element.