---
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>/trail-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 { MessageList } from '@/components/ui/goop/message-list';
import { Avatar } from '@/components/ui/goop/avatar';
import { IconButton, IconButtonIcon } from '@/components/ui/goop/icon-button';

<MessageList aria-label="Conversation with Ngozi" className="h-96">
  <ChatMessage author="Ngozi Ilori" avatar={<Avatar variant="solid" name="Ngozi Ilori">NI</Avatar>} time="09:41" dateTime="2026-11-19T09:41">
    Looks good. One thing: the empty state still says sessions.
  </ChatMessage>
  <ChatMessage
    author="Ngozi Ilori"
    time="09:42"
    continued
    actions={
      <>
        <ChatMessageCopy />
        <IconButton variant="ghost" size="sm" aria-label="Add a reaction">
          <IconButtonIcon icon="mood-plus" />
        </IconButton>
      </>
    }
  >
    Can we keep the old label for a week?
  </ChatMessage>
  <ChatMessage from="self" author="You" time="09:44" status="failed" onRetry={send}>
    On it.
  </ChatMessage>
  <ChatMessage author="Assistant" avatar={<Avatar variant="solid" name="Assistant">AI</Avatar>} time="09:46" streaming>
    Last week's 11 interviews mostly mention the consent
  </ChatMessage>
  <ChatMessage author="Assistant" avatar={<Avatar variant="solid" name="Assistant">AI</Avatar>} time="09:47">
    <ChatMessageThinking>Thinking…</ChatMessageThinking>
  </ChatMessage>
  <ChatMessage
    author="Assistant"
    avatar={<Avatar variant="solid" name="Assistant">AI</Avatar>}
    time="09:47"
    sources={[
      { title: 'Interview notes, week 46', kind: 'document', href: '/notes/week-46' },
      { title: 'Consent form wording', kind: 'pdf', href: '/files/consent-form.pdf' },
    ]}
    actions={<ChatMessageCopy />}
  >
    Seven of the eleven interviews mention the consent step.
  </ChatMessage>
  <ChatMessage from="self" author="You" time="09:48" variant="note">
    Ngozi asked for the new label by Friday.
  </ChatMessage>
</MessageList>
```

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

## API reference

### Parts

- `ChatMessageCopy` — The action that copies a message's words, for its `actions` row; its props: chat-message--copy.md
- `ChatMessageThinking` — The status line a reply shows before its words; its props: chat-message--thinking.md

- data-slot values (to select a part by): chat-message, chat-message-actions, chat-message-body, chat-message-caption, chat-message-content, chat-message-copy, chat-message-header, chat-message-media, chat-message-note, chat-message-note-icon, chat-message-note-label, chat-message-source, chat-message-sources, chat-message-status, chat-message-status-icon, chat-message-status-text, chat-message-thinking, chat-message-thinking-line, chat-message-thinking-text, chat-message-title, chat-message-word

### 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 words at rest.
- copiedLabel?: string = 'Copied' — Its words once the message's words are on the clipboard.
- failedLabel?: string = 'Couldn’t copy' — Its words when the clipboard refused them or there is none.
- Also takes: onClick?: (event: MouseEvent) => void; disabled?: boolean; loading?: boolean = false; loadingLabel?: string = 'Loading'

### ChatMessage: every option

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

### Options

- from?: 'self' | 'other' = 'other' — Who wrote it: the reader (`self`, at the end in a fill) 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"`; `from="self"` draws none.
- 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, more), 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.

### ChatMessageThinking

The status line a reply shows before its words.

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

### Options

- children: string — The words of the status ("Thinking…"); a change crossfades to the new words.

## Accessibility

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

## 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.

## Related

- [Message list](/themes/trail/components/message-list): The messages of one conversation in a column, the newest at one end, as they arrive.
- [Avatar](/themes/trail/components/avatar): A person's or a team's picture or initials, beside their name or on its own.
- [Icon button](/themes/trail/components/icon-button): A button whose only visible label is one icon, for toolbars, rows and headers.
- [Composer](/themes/trail/components/composer): A box to write a message, a comment or a prompt in, with attachments and a send button, for a chat or a record's comments.
