AI Elements

Message

One turn in a chat. The user's sits right in a bubble; the assistant's renders Markdown with Streamdown and can carry actions.

packages/design-system/components/ai-elements/message.tsx

Examples

How long does a brand sprint take?
User

A brand sprint runs two weeks: a kickoff, two rounds of concepts, and a handover with the files and a short guide.

Assistant, with Markdown and actions

Anatomy

  1. 01Message, the row
  2. 02Content, a bubble for the user
  3. 03Response, Markdown
  4. 04Actions, ghost icon buttons

Usage

import {
  Message, MessageAction, MessageActions, MessageContent, MessageResponse,
} from "@repo/design-system/components/ai-elements/message";

<Message from={message.role}>
  <MessageContent>
    <MessageResponse>{part.text}</MessageResponse>
  </MessageContent>
  <MessageActions>
    <MessageAction tooltip="Copy" onClick={copy}><CopyIcon /></MessageAction>
  </MessageActions>
</Message>

Props

PropTypeDefaultDescription
from*"user" | "assistant" | "system"noneUser messages align right in a secondary bubble.
MessageResponse childrenstringnoneMarkdown, rendered by Streamdown with code, math, mermaid and CJK plugins. Re-renders only when the text changes.
MessageAction tooltip / labelstringnoneThe tooltip, and the screen reader label (falls back to the tooltip).
MessageBranch defaultBranch / onBranchChangenumber / (index) => voidnoneFor regenerated answers: page between versions with MessageBranchSelector.
classNamestringnoneMerged last with cn(). Use it for layout (width, margin), not to restyle the component.

Guidance

Do

  • Use MessageResponse for anything the model wrote.

Don't

  • Render model output with dangerouslySetInnerHTML.

Where it's used