DocsComponentsTemplatesThemesGitHub

ChatMessage

One chat turn: user bubble on the right, assistant text on the left with avatar, attachments and actions.

Code

import * as React from 'react';
import { AttachmentChip, ChatMessage, Citation, MessageActions } from '@fruit-labs/design';

export default function Demo() {
  return (
    <div
      style={{
        display: 'flex',
        flexDirection: 'column',
        gap: 18,
        maxWidth: 640,
      }}
    >
      <ChatMessage role="user" attachments={<AttachmentChip name="q3-report.pdf" size="1.2 MB" />}>
        Summarize the attached report in three bullets.
      </ChatMessage>
      <ChatMessage
        name="Assistant"
        actions={
          <MessageActions
            text="..."
            {...{
              onRetry() {},
            }}
          />
        }
      >
        <p>
          Here are the key points
          <Citation n={1} />:
        </p>
        <p>Revenue grew in every region, led by APAC.</p>
      </ChatMessage>
      <ChatMessage name="Assistant" streaming>
        Drafting the follow-up email
      </ChatMessage>
    </div>
  );
}

Streaming reply

import { ChatMessage } from '@fruit-labs/design';

export default function Example() {
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 12, maxWidth: 560 }}>
      <ChatMessage role="assistant" name="Orchard AI" streaming>Reading your invoices</ChatMessage>
    </div>
  );
}

Install

From npm:

npm install @fruit-labs/design

import { ChatMessage } from '@fruit-labs/design';

Or copy the TypeScript source into your project:

npx shadcn@latest add https://design.fruitlabs.online/r/chat-message.json

Guidelines

  • Assistant replies are unboxed text for readability; user messages sit in a fill bubble.
  • Set streaming while tokens arrive (blinking caret). Put MessageActions under finished replies.

Props

PropTypeRequired
role'user' | 'assistant' | 'system'No
namestringNo
avatarReact.ReactNodeNo
streamingbooleanNo
attachmentsReact.ReactNodeNo
actionsReact.ReactNodeNo
classNamestringNo
childrenReact.ReactNodeNo

Edit this example on GitHub