Docs
Chat Message

A customizable message bubble component for chat interfaces with support for user and AI messages.

Loading...

The ChatMessage component provides a styled message bubble with support for markdown content, timestamps, animations, and contextual actions.

Installation

pnpm dlx shadcn@latest add https://devkit.kiron.dev/k/chat-message

Usage

import { ChatMessage } from "@/components/ui/chat-message"
 
export function ChatDemo() {
  return (
    <div className="space-y-4">
      <ChatMessage
        role="user"
        content="Hello, how are you?"
        createdAt={new Date()}
        showTimeStamp
      />
      <ChatMessage
        role="assistant"
        content="I'm doing well, thank you for asking!"
        createdAt={new Date()}
        showTimeStamp
      />
    </div>
  )
}

Examples

Different Animation Styles

Loading...

With Actions

Loading...

With Timestamp

Loading...

Accessibility

  • Messages are properly structured for screen readers
  • Timestamps use semantic HTML
  • Actions are keyboard accessible
  • Color contrast meets WCAG guidelines

Props

PropTypeDefaultDescription
role"user" | "assistant" | stringRequiredThe role of the message sender
contentstringRequiredThe message content (supports markdown)
createdAtDate-Timestamp for the message
showTimeStampbooleanfalseWhether to show the timestamp
animation"none" | "slide" | "scale" | "fade""scale"Animation style for the message bubble
actionsReactNode-Actions to show on hover (assistant only)
idstringRequiredUnique identifier for the message
attachmentsFile[]-Array of attached files