# MessagePrimitive
URL: /docs/api-reference/primitives/message
Components for rendering message content, parts, and attachments.
A single message in a conversation. Messages may consist of multiple parts.
Anatomy \[#anatomy]
```tsx
import { MessagePrimitive } from "@assistant-ui/react";
const UserMessage = () => (
User:
);
const AssistantMessage = () => (
Assistant:
);
```
API Reference \[#api-reference]
Root \[#root]
Containts all parts of the message.
This primitive renders a `
` element unless `asChild` is set.
Parts \[#parts]
The content of the message. This renders a separate component for each content part of the message.
",
description:
"The components to render for each tool call content part.",
},
{
name: "Fallback",
type: "ToolCallContentPartComponent",
description:
"The fallback component to render for tool call content parts.",
},
],
},
],
},
{
name: "ToolGroup",
type: "ComponentType>",
description:
"Component for rendering grouped consecutive tool calls. When provided, consecutive tool-call content parts will be automatically grouped and wrapped with this component.",
children: [
{
type: "ToolGroupProps",
parameters: [
{
name: "startIndex",
type: "number",
description: "Index of the first tool call in the group.",
required: true,
},
{
name: "endIndex",
type: "number",
description: "Index of the last tool call in the group.",
required: true,
},
{
name: "children",
type: "ReactNode",
description:
"The rendered tool call components within the group.",
required: true,
},
],
},
],
},
],
},
],
},
]}
/>
PartByIndex \[#partbyindex]
Renders a single message part at the specified index.
```tsx
```
Attachments \[#attachments]
Renders all attachments of the message.
AttachmentByIndex \[#attachmentbyindex]
Renders a single attachment at the specified index within the message.
```tsx
```
useMessageQuote() \[#usemessagequote]
A hook that returns the quote info attached to the current message, if any. Reads from `message.metadata.custom.quote`.
```tsx
import { useMessageQuote } from "@assistant-ui/react";
const QuoteBlock = () => {
const quote = useMessageQuote();
if (!quote) return null;
return (
{quote.text}
);
};
```
**Returns:** `QuoteInfo | undefined`
```typescript
type QuoteInfo = {
readonly text: string; // the quoted plain text
readonly messageId: string; // the source message ID
};
```
See the [Quoting guide](/docs/guides/quoting) for a complete walkthrough.
Error \[#error]
Renders children only if the message has an error status.
```tsx
{/* rendered if the message has an error status */}
```