Message
A chat message row with an avatar, name, bubbles and status, where new messages rise in from the sender's side.
- Chat UI components
- 6 parts
- 6 examples
@base-ui/react
See it in a real product: Chat Thread, Model Compare, Streaming, and 1 more
View blockpnpm dlx shadcn@latest add https://hextaui.com/r/message.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add @base-ui/react class-variance-authority cnCopy and paste the following code into your project.
components/ui/message.tsx components/ui/bubble.tsx Update the import paths to match your project setup.
A message lays out an avatar, a name, one or more <Bubble />s and a status line. Bubbles inherit the message's align, so you set it once.
align="end" puts the avatar and bubbles on the other side for your own messages.
<MessageHeader /> holds the name and time, and <MessageFooter /> a single line of status. The avatar always lines up with the last bubble, with or without a footer.
A ghost bubble spans the full width for long answers, and an icon in <MessageAvatar /> becomes a round tile.
Bubbles wrap long links, and header and footer text can truncate without pushing the avatar.
Start and end swap sides, and new messages grow from the matching corner.
- Messages are plain content. For a live chat, wrap the list in a
role="log"element so screen readers read new messages as they arrive. - Put the sender's name in a header or in visually hidden text, since alignment alone doesn't say who wrote a message.
- The entrance only plays for messages added after the list first renders. With reduced motion they fade in.
Every part renders a <div> and accepts render.
The thread. Messages added after its first render animate in.
| Attribute | Description |
|---|---|
data-slot="message-group" | Target the thread in CSS. |
| Prop | Type | Default |
|---|---|---|
alignSide of the conversation. Bubbles inherit it. | "start" | "end" | "start" |
animatedRise in when added to a MessageGroup after its first render. | boolean | true |
render | ReactElement | (props, state) => ReactElement | <div> |
| Attribute | Description |
|---|---|
data-slot="message" | Target messages in CSS. |
data-align | The side. |
data-entering | Present on messages that animate in. |
| Attribute | Description |
|---|---|
data-slot="message-avatar" | Lines up with the last bubble. A bare icon or image is sized to 32px. |
| Attribute | Description |
|---|---|
data-slot="message-content" | Stacks the header, bubbles and footer. |
| Attribute | Description |
|---|---|
data-slot="message-header" | Name and time above the bubbles. |
data-slot="message-footer" | One line of status below. Keep it to a single line so the avatar stays aligned. |
- BubbleChat message bubbles with variants, grouped corners, reactions and room for interactive content.
- AvatarUser photos with an initials fallback, status badges and stacked groups that collapse into a count.
- AttachmentFile and image cards for uploads, with progress, states, actions, a full-card trigger and names that keep their extension.
- MarkerQuiet notes between content, like date dividers and system events, with sticky dates and times that read as Today or Yesterday.
- Message scrollerA chat scroll area that follows new messages, keeps your place while you read back, and counts what you missed on the jump button.
Used in Pro blocks
Blocks that build on Message.
Every block comes with HextaUI Pro, and Prompt Input is free.