Message

A component for displaying messages in a conversation interface, with support for avatars, markdown content, and interactive actions.

Examples

Basic Message

Hello! How can I help you today?
AI

I can help with a variety of tasks: - Answering questions - Providing information - Assisting with coding - Generating creative content What would you like help with today?

Message with Actions

You can use MessageActions and MessageAction to add interactive elements to your messages.

Hello! How can I help you today?
AI

I can help with a variety of tasks: - Answering questions - Providing information - Assisting with coding - Generating creative content What would you like help with today?

Installation

npx shadcn add "https://prompt-kit.com/c/message.json"

Component API

Message

PropTypeDefaultDescription
childrenReact.ReactNodeChild components to render
classNamestringAdditional CSS classes
...propsReact.HTMLProps<HTMLDivElement>All other div props

MessageAvatar

PropTypeDefaultDescription
srcstringURL of the avatar image
altstringAlt text for the avatar image
fallbackstringText to display if image fails to load
delayMsnumberDelay before showing fallback (in ms)
classNamestringAdditional CSS classes

MessageContent

PropTypeDefaultDescription
childrenReact.ReactNodeContent to display in the message
markdownbooleanfalseWhether to render content as markdown
classNamestringAdditional CSS classes
...propsReact.HTMLProps<HTMLDivElement>All other div props

MessageActions

PropTypeDefaultDescription
childrenReact.ReactNodeChild components to render
classNamestringAdditional CSS classes
...propsReact.HTMLProps<HTMLDivElement>All other div props

MessageAction

PropTypeDefaultDescription
tooltipReact.ReactNodeContent to show in the tooltip
childrenReact.ReactNodeChild component to trigger the tooltip
classNamestringAdditional CSS classes for the tooltip
side"top" | "bottom" | "left" | "right""top"Position of the tooltip relative to the trigger
...propsReact.ComponentProps<typeof Tooltip>All other Tooltip component props