---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Chat message

One message of a conversation: its author, its body and when it was sent, often an avatar and actions, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `ChatMessage`.

## Try it

Ask one of the three questions: your message shows “Sending…”, the first one fails and offers Retry, then the reply thinks for a moment and streams in. Copy a finished reply with its Copy button.

The assistant is a timer with three answers of our own; the first send fails on purpose.

## When to use

- One message of a conversation: its author, its body and when it was sent, often an avatar and actions.
- Also called: message bubble.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Chat message on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-chat-message.json --yes
```

```text
Add the Goop Chat message to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { ChatMessage, ChatMessageCopy, ChatMessageThinking } from '@/components/ui/goop/chat-message';
import { IconButton, IconButtonIcon } from '@/components/ui/goop/icon-button';

function Answer({ thinking, onDelete }: { thinking: boolean; onDelete: () => void }) {
  return (
    <div className="flex flex-col">
      <ChatMessage from="self" variant="question" author="You" time="09:45">
        Which events moved this month?
      </ChatMessage>
      <ChatMessage
        author="Assistant"
        time="09:46"
        sources={[{ title: 'November events plan', kind: 'document', href: '/plans/november' }]}
        actions={
          <>
            <ChatMessageCopy />
            <IconButton aria-label="Delete" onClick={onDelete}>
              <IconButtonIcon icon="trash" />
            </IconButton>
          </>
        }
      >
        {thinking ? (
          <ChatMessageThinking>Thinking…</ChatMessageThinking>
        ) : (
          <>
            <p>Two events moved:</p>
            <ol>
              <li>
                <strong>Farmers' market</strong> to Saturday
              </li>
              <li>
                <strong>Volunteer rota</strong> to nine
              </li>
            </ol>
          </>
        )}
      </ChatMessage>
    </div>
  );
}
```

- Fits: chat, inbox (their recipes).
- height, width, padding, gap, corner, background, text, motion: add no class for these.

## API reference

### Options

- `from?: 'self' | 'other' = 'other'` — Who wrote it: the reader (`self`, a bubble at the end; with `variant="question"`, the question in the heading type) or another person (`other`).
- `author: ReactNode` — The author's name ("You" for the reader's own); with the time, the message's name.
- `avatar?: ReactNode` — Another person's `Avatar variant="solid"`, in a 24 px gutter; with none, no gutter.
- `time: ReactNode` — The time as the heading shows it ("09:41", "Yesterday").
- `dateTime?: string` — The time for a machine (ISO), on the heading's `time` element.
- `continued?: boolean = false` — The message follows another of the same author: its avatar and heading hidden, still read.
- `status?: 'sent' | 'sending' | 'failed' = 'sent'` — Posted (`sent`), on its way (`sending`) or refused (`failed`, with the red mark and the retry).
- `statusLabel?: string` — The status line's words in place of "Sending" or "Not sent".
- `onRetry?: () => void` — Called by the failed message's retry button; with none, no retry is offered.
- `retryLabel?: string = 'Retry'` — The retry button's words.
- `actions?: ReactNode` — The caller's buttons for this message (copy, delete), in one row under the words.
- `sources?: readonly ChatMessageSource[]` — What the message cites, in a list under the words and above the actions: each a link (`href`) or a button (`onSelect`) with its kind's mark and its title; held back while the message streams.
- `sourcesLabel?: string = 'Sources'` — The sources list's name for a screen reader.
- `streaming?: boolean = false` — The message is still arriving: each new word fades in; busy until it ends.
- `variant?: 'default' | 'note' | 'question' = 'default'` — `note`: a note for the writer's team, in a faint warm box under its label.
- `noteLabel?: string = 'Internal note'` — The note's label words ("Internal note").
- `children: ReactNode` — The words of the message.

### Parts

- `ChatMessageCopy` — The action that copies a message's words, for its `actions` row; its props: chat-message--copy.md
- `ChatMessageThinking` — The line a reply shows before its words; children: string — The words of the status ("Thinking…"); a change crossfades to the new words

### ChatMessageCopy

The action that copies a message's words, for its `actions` row.

```tsx
import { ChatMessageCopy } from '@/components/ui/goop/chat-message';
```

### Options

- label?: string = 'Copy' — The button's name and tooltip.
- copiedLabel?: string = 'Copied' — What its status says once the message's words are on the clipboard.
- failedLabel?: string = 'Couldn’t copy' — What its status says when the clipboard refused them or there is none.
- Also takes: onClick?: (event: MouseEvent) => void; disabled?: boolean; loading?: boolean = false; loadingLabel?: string = 'Loading'

## Accessibility

- hover: the browser's own (:hover): write nothing
- focus-visible: the attribute data-focus-visible

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

Shortened to fit: the data-slot values.

## Related

- [Icon button](/themes/meadow/components/icon-button): A button whose one visible label is a pack icon, for toolbars, rows and headers, with a spoken name.
- [Message list](/themes/meadow/components/message-list): The messages of one conversation in a column, the newest at one end, as they arrive.
- [Composer](/themes/meadow/components/composer): A box to write a prompt, a comment, a reply or an email in, with attachments and a send button.
- [Attachment list](/themes/meadow/components/attachment-list): The files chosen to send, under a composer or a form field.
