---
title: "Message"
description: "Composable conversation primitives for message rows, grouped bubbles, avatars, metadata, live markers, and a mount-only trailing-edge pop-up for newly sent rows."
category: "AI Agents"
publishedAt: "2026-08-02"
updatedAt: "2026-11-25"
documentation: "https://beui.dev/components/agents/message"
markdown: "https://beui.dev/components/agents/message.md"
license: "MIT"
---

# Message

> Composable conversation primitives for message rows, grouped bubbles, avatars, metadata, live markers, and a mount-only trailing-edge pop-up for newly sent rows.

## Install

```bash
npx shadcn@latest add @beui/message
```

## Dependencies

- `@floating-ui/dom`
- `clsx`
- `lucide-react`
- `motion`
- `react`
- `react-dom`
- `tailwind-merge`

## Usage

```tsx
"use client";

import {
  Message,
  MessageAvatar,
  MessageContent,
  MessageFooter,
  MessageGroup,
  MessageHeader,
} from "@/components/agents/message";
import {
  MessageBubble,
  MessageBubbleContent,
} from "@/components/agents/message-bubble";

export function MessageUsage() {
  return (
    <MessageGroup spacing="default">
      <Message from="user" animateIn>
        <MessageAvatar>Y</MessageAvatar>
        <MessageContent>
          <MessageHeader>
            <span>You</span>
            <span>Now</span>
          </MessageHeader>
          <MessageBubble variant="solid">
            <MessageBubbleContent>
              Can you summarize the release notes?
            </MessageBubbleContent>
          </MessageBubble>
          <MessageFooter>Delivered</MessageFooter>
        </MessageContent>
      </Message>

      <Message from="assistant">
        <MessageAvatar>AI</MessageAvatar>
        <MessageContent>
          <MessageHeader>
            <span>Assistant</span>
            <span>Just now</span>
          </MessageHeader>
          <MessageBubble variant="soft">
            <MessageBubbleContent>
              The release improves streaming, navigation, and recovery states.
            </MessageBubbleContent>
          </MessageBubble>
        </MessageContent>
      </Message>
    </MessageGroup>
  );
}
```

## API Reference

### Message

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `from` | `"user" \| "assistant"` |  | Yes | Who sent it; "user" rows align to the end, "assistant" rows to the start. |
| `animateIn` | `boolean` | `false` | No | Plays a trailing-edge pop-up once when this message row mounts. |
| `labels` | `Partial<{ user: string; assistant: string; typing: string; }>` |  | No | Override any built-in string. |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageGroup

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `spacing` | `"default" \| "compact"` | `compact` | No | Gap between messages: 6 px for "compact", 16 px for "default". Default: "compact" |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageAvatar

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `placeholder` | `boolean` | `false` | No | Keep an empty avatar slot so grouped messages remain aligned. |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageContent

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageHeader

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageFooter

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageMarker

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageTyping

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `label` | `string` |  | No | Screen reader text for the typing dots. Default: "Responding" |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageBubble

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `variant` | `"outline" \| "ghost" \| "danger" \| "solid" \| "soft" \| "tint"` | `soft` | No | Fill and border style of the bubble. Default: "soft" |
| `align` | `"start" \| "end"` |  | No | Defaults to the surrounding Message alignment when omitted. |
| `animateIn` | `boolean` | `false` | No | Plays the bubble entrance once when this component mounts. |
| `labels` | `Partial<{ showMore: string; showLess: string; }>` |  | No | Override any built-in string. |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageBubbleCollapsible

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `open` | `boolean` |  | No | Whether the full text shows, for controlled use. |
| `defaultOpen` | `boolean` | `false` | No | Whether the full text shows at first when uncontrolled. Default: false |
| `onOpenChange` | `((open: boolean) => void)` |  | No | Called with the new state when the text expands or collapses. |
| `collapsedLines` | `2 \| 6 \| 3 \| 4 \| 5` | `4` | No | Lines shown while collapsed. Default: 4 |
| `moreLabel` | `ReactNode` |  | No | Text of the expand button. Default: "Show more" |
| `lessLabel` | `ReactNode` |  | No | Text of the collapse button. Default: "Show less" |
| `contentClassName` | `string` |  | No | Classes merged onto the clamped text wrapper. |
| `triggerClassName` | `string` |  | No | Classes merged onto the show more button. |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageBubbleContent

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `render` | `ReactElement<unknown, string \| JSXElementConstructor<any>>` |  | No | Replaces the content element while preserving bubble styling. |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageBubbleGroup

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `spacing` | `"default" \| "compact"` | `compact` | No | Gap between bubbles. Default: "compact" |
| `className` | `string` |  | No | Classes merged onto the root element. |

### MessageScroller

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `followOutput` | `boolean` | `true` | No | Keep streamed output pinned while the reader remains near the end. |
| `followThreshold` | `number` | `56` | No | Distance from the end that still counts as following the output. |
| `smooth` | `boolean` | `true` | No | Smoothly follow growing content. |
| `onFollowChange` | `((following: boolean) => void)` |  | No | Reports when the reader leaves or returns to the live edge. |
| `label` | `string` |  | No | Accessible label for the scrollable transcript. |
| `busy` | `boolean` |  | No | Marks the transcript as waiting for more streamed content. |
| `navigation` | `"rail"` |  | No | Adds a compact rail for navigating between rendered Message rows. |
| `jumpButton` | `boolean` | `true` | No | Shows a button back to the latest message once the reader scrolls up. Default true. |
| `navigationLabel` | `string` |  | No | Accessible label for the optional message navigation rail. |
| `viewportClassName` | `string` |  | No | Classes merged onto the scrolling viewport. |
| `contentClassName` | `string` |  | No | Classes merged onto the log element that wraps the messages. |
| `railClassName` | `string` |  | No | Classes merged onto the navigation rail, used with `navigation="rail"`. |
| `viewportRef` | `Ref<HTMLElement>` |  | No | Ref to the scrolling viewport element. |
| `viewportProps` | `Omit<DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>, "children" \| "className" \| "ref">` |  | No | Extra props for the scrolling viewport. Its event handlers still run. |
| `contentProps` | `Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children" \| "className" \| "ref">` |  | No | Extra props for the log element that wraps the messages. |
| `labels` | `Partial<{ label: string; jumpToLatest: string; navigationLabel: string; preview: string; goToUser: string; goToAssistant: string; goToMessage: string; }>` |  | No | Override any built-in string. |
| `className` | `string` |  | No | Classes merged onto the root element. |

## Composition

Build each conversation row from independent identity, content, and metadata primitives.

```text
MessageGroup
└── Message
    ├── MessageAvatar
    └── MessageContent
        ├── MessageHeader
        ├── MessageBubble
        └── MessageFooter
```

- `message-bubble`: Supplies the visual surface inside the row.
- `message-scroller`: Positions message rows inside a reader-aware transcript.
- `agent-activity`: Renders progressive agent work as message content.

### How it works

A message is a conversation row. It coordinates the avatar, metadata, content surface, and delivery details while allowing the content itself to be a bubble, an agent activity, a tool result, or a composed response.

- **Establish the sender.** Alignment, avatar, and metadata locate the row in the conversation.
- **Compose the payload.** A bubble, response, activity stream, or tool surface fills the content slot.
- **Hold its position.** The row stays stable while its inner content streams or changes state.

### What it owns and what it leaves to you

- **Owns:** Row alignment, avatar placement, metadata slots, grouping, and one-time entrance motion.
- **Leaves to the app:** Bubble styling, transcript scrolling, response parsing, and persistence to composed primitives and application state.

### Principles

- **Compose the row.** Keep identity and metadata outside the message surface. This preserves alignment when the visible content changes shape.
- **Group by speaker.** Consecutive messages can share rhythm and avatar placement without losing their individual semantic boundaries.
- **Animate only arrivals.** A newly sent row may pop into place once. Existing rows remain still when text streams or the composer updates.

### Use it when

Content needs sender alignment, identity, metadata, or grouping inside a conversation.

### Avoid it when

You only need a visual content surface with no conversation-level identity or row layout.

## About Message

Message is a composable conversation row for React AI chat interfaces. Message sets the sender with from (user or assistant) and aligns everything for that side, while MessageAvatar, MessageHeader, MessageContent and MessageFooter fill in identity, metadata and delivery details. MessageGroup stacks consecutive rows, MessageMarker adds centered dividers such as dates, and MessageTyping shows a typing indicator. An opt-in animateIn prop makes a newly sent row rise from the live edge with a Framer Motion spring.

### When to use it

- An AI assistant chat needs user and assistant rows with avatars, names, timestamps and actions.
- A transcript groups consecutive messages from one sender under a single avatar.
- A conversation needs inline dividers, such as a date or "Model changed", between rows.

### Accessibility

Each row renders as an article labeled by sender, for example "user message", unless you pass your own aria-label. MessageTyping includes a visually hidden label ("Responding" by default) so screen readers hear what the dots mean, and a placeholder MessageAvatar is hidden from assistive technology. With reduced motion enabled, the entrance rise and typing bounce are removed and only opacity changes remain.

### FAQ

**How do I build a chat message list in React?**

Render one Message per item with from set to user or assistant, and compose MessageAvatar, MessageContent with a MessageBubble, and optional MessageHeader and MessageFooter inside it.

**Can I use it with the Vercel AI SDK?**

Yes. Message does not own data or transport, so you map each message from useChat to a Message row, setting from from its role and rendering its parts inside MessageContent.

**How do I keep grouped messages aligned without repeating the avatar?**

Wrap the rows in MessageGroup and give later rows a MessageAvatar with placeholder set. It keeps the slot width so content stays aligned.

## React Native

A React Native version ships in beUI Native. The detail JSON has every file to copy.

```bash
npx expo install react-native-gesture-handler react-native-reanimated react-native-svg react-native-worklets
npm install uniwind tailwindcss
```

- Native detail: https://beui.dev/native/r/message
- GitHub: https://github.com/starc007/beui-native/tree/main/src/components/message

## Source

- Registry detail: https://beui.dev/r/message
- Raw source: https://beui.dev/r/message/raw
- GitHub: https://github.com/starc007/ui-components
