View fulldotdev/ui on GitHub

Message

Displays a message in a conversation, with optional avatar, header, footer, and alignment.

Installation

npx shadcn@latest add @fulldev/message

Usage

import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
import { Message, MessageAvatar, MessageContent } from "@/components/ui/message"
<Message>
  <MessageAvatar>
    <Avatar>
      <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
      <AvatarFallback>CN</AvatarFallback>
    </Avatar>
  </MessageAvatar>
  <MessageContent>
    <Bubble>
      <BubbleContent>How can I help you today?</BubbleContent>
    </Bubble>
  </MessageContent>
</Message>

Note: Message owns the row layout, avatar, alignment, header, and footer. Render the visible message surface inside it with Bubble. For the scroll container around a conversation, use MessageScroller.

Composition

Use the following composition to build a message:

Message
├── MessageAvatar
└── MessageContent
    ├── MessageHeader
    ├── Bubble
    └── MessageFooter
MessageGroup
├── Message
└── Message

Avatar

Use MessageAvatar to render an avatar next to the message.

alignDescription
startAlign the message to the start of the conversation.
endAlign the message to the end of the conversation.

Group

Use MessageGroup to stack consecutive messages from the same sender.

Use MessageHeader for a sender name and MessageFooter for metadata such as a delivery or read status.

Actions

Place message-level actions in MessageFooter, such as copy, retry, or feedback buttons.

Attachment

Accessibility

Message is a presentational layout wrapper.

Label icon-only actions

Action buttons in MessageFooter are usually icon-only, so give each one an aria-label.

<MessageFooter>
  <Button variant="ghost" size="icon" aria-label="Copy">
    <CopyIcon />
  </Button>
</MessageFooter>

Status updates

For in-progress messages, use a Marker with role="status" so assistive tech announces the update as it appears.

<Message>
  <Marker role="status">
    <MarkerIcon>
      <Spinner />
    </MarkerIcon>
    <MarkerContent>Checking the logs...</MarkerContent>
  </Marker>
</Message>

API Reference

Source: react/src/components/ui/message.tsx

Message

The message row wrapper.

PropTypeDefaultDescription
align"start" | "end""start"The alignment of the message in the conversation.
classNamestring-Additional classes to apply to the row.

MessageGroup

Groups consecutive messages from the same sender.

PropTypeDefaultDescription
classNamestring-Additional classes to apply to the group root.

MessageAvatar

The avatar slot, aligned to the bottom of the message.

PropTypeDefaultDescription
classNamestring-Additional classes to apply to the avatar slot.

MessageContent

Wraps the header, message surface, and footer.

PropTypeDefaultDescription
classNamestring-Additional classes to apply to the content slot.

MessageHeader

Displays content above the message, such as a sender name.

PropTypeDefaultDescription
classNamestring-Additional classes to apply to the header.

MessageFooter

Displays content below the message, such as status or actions.

PropTypeDefaultDescription
classNamestring-Additional classes to apply to the footer.