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 Markdown

The markdown prop enables rendering content as Markdown, perfect for rich text formatting in messages.

AI
Hello World! This message supports bold text, italics, and other Markdown features.

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

Copy and paste the following code into your project.

pnpm dlx shadcn-svelte@latest add https://ai-elements.vercel.app/r/prompt-kit-message.json

Component API

Message

PropTypeDefaultDescription
childrenSnippet-Child components to render
classNamestring-Additional CSS classes
...propsHTMLAttributes<HTMLDivElement>-All other div props are supported

MessageAvatar

PropTypeDefaultDescription
srcstring-URL of the avatar image
altstring-Alt text for the avatar image
fallbackstring-Text to display if image fails to load
classNamestring-Additional CSS classes

MessageContent

PropTypeDefaultDescription
childrenSnippet-Content to display in the message
markdownbooleanfalseWhether to render content as markdown
classNamestring-Additional CSS classes
...propsHTMLAttributes<HTMLDivElement>-All other div props are supported

MessageActions

PropTypeDefaultDescription
childrenSnippet-Child components to render
classNamestring-Additional CSS classes
...propsHTMLAttributes<HTMLDivElement>-All other div props are supported

MessageAction

PropTypeDefaultDescription
tooltipSnippet-Content to show in the tooltip
childrenSnippet-Child component to trigger the tooltip
classNamestring-Additional CSS classes for the tooltip
side"top" | "bottom" | "left" | "right""top"Position of the tooltip relative to the trigger
...propsTooltipProps-All other Tooltip component props are supported