# Message

One user, assistant or system message with its parts and references.

- **Use it for**: One message with its ordered parts, sources, tools and attachments.
- **Not for**: A whole conversation surface. Try [Chat](https://unseenui.com/components/chat/).

## Good to know

- In the chat variant a Markdown reply reads at the message size (16px), not the interface size.
- Earlier replies keep their actions hidden until hovered or focused; the last reply always shows them.

## Installation

```bash
npm install @stackunseen/ui
```

## Parts

Message draws one message. Its content and actions are components of their own, so you can use them in your own layout too.

```tsx
<Message value={message}>
  <MessageActions text={text} onRetry={retry} onFeedback={rate} />
</Message>
```

1. **`Message`**: Who sent it and when, then the content. Children go after it. Props: `value`, `variant`, `renderContent`.
2. **`MessageContent`**: Text, reasoning, files, sources and tool calls. `renderContent` replaces it. Built from StreamingResponse, ToolCall, Attachment, Citation. Props: `value`, `renderTextPart`, `renderTool`, `responseVariant`, `sources`, `tools`, `attachments`.
3. **`MessageActions`**: Copy, plus Retry, Edit and feedback for the callbacks you pass. Props: `text`, `onRetry`, `retryAvailability`, `retryLabel`, `onEdit`, `editAvailability`, `onFeedback`, `feedbackValue`.

## Usage

```tsx
import { Message } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<Message variant="plain" value={message} />
```

## Props

- `value` (`MessageData`): The id, role, state and revision, with either text or parts as its content.
- `sources` (`readonly Source[] (optional)`): Source records matched to source parts by sourceId. Keep ids unique.
- `tools` (`readonly ToolCallData[] (optional)`): Tool records matched to tool parts by toolCallId. Keep ids unique.
- `attachments` (`readonly MessageAttachment[] (optional)`): Attachment records matched by id and version, including access and preview data.
- `renderTextPart` (`(part: TextMessagePart, variant: ComponentVariant<'StreamingResponse'>) => ReactNode (optional)`): Render each text part, for example as Markdown. Keep the callback stable.
- `children` (`ReactNode (optional)`): Content after the message body, such as MessageActions or extra attachments.

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `attachments` | `readonly MessageAttachment[]` |  |
| `renderContent` | `((message: MessageData) => ReactNode)` | Replaces only the response body; children remain after it for actions/attachments. |
| `renderTextPart` | `((part: TextMessagePart, variant: ComponentVariant<"StreamingResponse">) => ReactNode)` | Keep the callback stable to preserve completed-part memoization. |
| `renderTool` | `((tool: ToolCallData) => ReactNode \| undefined)` | Host view for a tool call. |
| `responseVariant` | `"cursor" \| "dots" \| "shimmer"` |  |
| `sources` | `readonly Source[]` |  |
| `tools` | `readonly ToolCallData[]` |  |
| `value` (required) | `MessageData \| MessageInput` | Host data, or the short form `{ role, text }` for prototypes. |
| `variant` | `"panel" \| "plain" \| "bubble" \| "chat"` |  |

## Keyboard

The message itself is an article. Tab reaches the links, disclosures and actions inside it; their controls handle keyboard interaction.

## Works with

[Chat](https://unseenui.com/components/chat/), [PromptInput](https://unseenui.com/components/prompt-input/), [StreamingResponse](https://unseenui.com/components/streaming-response/), [MessageActions](https://unseenui.com/components/message-actions/), [Suggestions](https://unseenui.com/components/suggestions/), [Attachment](https://unseenui.com/components/attachment/), [AttachmentTray](https://unseenui.com/components/attachment-tray/), [FileDropzone](https://unseenui.com/components/file-dropzone/), [ModelSelector](https://unseenui.com/components/model-selector/), [FeedbackCapture](https://unseenui.com/components/feedback-capture/), [Reasoning](https://unseenui.com/components/reasoning/), [SuggestTextarea](https://unseenui.com/components/suggest-textarea/)

Page: https://unseenui.com/components/message/
