---
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/"
---

# Comment thread

A record's discussion: replies, reactions, resolve, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `CommentThread`.

## When to use

- A record's discussion: replies, reactions, resolve.

## 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 Comment thread 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-comment-thread.json --yes
```

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

## Usage

```tsx
import { defaultReactionChoices, ReactionBar, CommentThread } from '@/components/ui/goop/comment-thread';
import { useState } from 'react';

function Discussion() {
  const first = {
    id: 'c1',
    author: { name: 'Ngozi Ilori' },
    time: '2 hours ago',
    body: 'The tags come back after a sync on a slow connection.',
    reactions: [{ emoji: '👍', label: 'Thumbs up', count: 2 }],
  };
  const [replies, setReplies] = useState([
    { id: 'r1', author: { name: 'Yuto Sakamaki' }, time: '1 hour ago', body: 'Same here on the Thursday build.' },
  ]);
  const [resolved, setResolved] = useState(false);
  const me = { name: 'Teodora Valk' };
  return (
    <CommentThread
      comment={first}
      replies={replies}
      onReply={(text) =>
        setReplies((all) => [...all, { id: `r${all.length + 1}`, author: me, time: 'Just now', body: text }])
      }
      resolved={resolved}
      onResolve={() => setResolved(true)}
      onReopen={() => setResolved(false)}
    />
  );
}
```

- Fits: record (its recipe).
- On a record page it stands in the activity column under the record's history (ActivityItem rows), one thread per discussion; a new discussion starts in the page's own Composer (`variant="comment"`), whose send adds a thread.
- ReactionBar: A comment thread draws one under each comment; on its own it serves any item people react to (a post, an update).
- width, padding, gap, corner, background, text: add no class for these.

## API reference

### Parts

- `ReactionBar` — A row of emoji reactions with their counts, and a button to add one; its props: comment-thread--reaction-bar.md
- `defaultReactionChoices` — The emoji the picker offers when the caller names none

- data-slot values (to select a part by): comment-thread, comment-thread-actions, comment-thread-comment, comment-thread-footer, comment-thread-replies, comment-thread-reply, comment-thread-status, reaction-bar, reaction-picker

### CommentThread: every option

```tsx
import { CommentThread } from '@/components/ui/goop/comment-thread';
```

### Options

- comment: ThreadComment — The thread's first comment.
- replies?: readonly ThreadComment[] = [] — The replies under it, oldest first.
- onReply?: (text: string) => void — Called with a reply's words (trimmed, never empty) when the reader sends it; add it to `replies`.
- onReact?: (commentId: string, reaction: ReactionChoice, reacted: boolean) => void — Called when the reader toggles a reaction on a comment: its id, the emoji, and whether they now react with it.
- reactionChoices?: readonly ReactionChoice[] — The emoji the picker offers; six common ones when left out.
- resolved?: boolean — Resolved (controlled): the thread folded to one line.
- defaultResolved?: boolean = false — Resolved from the start (uncontrolled).
- onResolve?: () => void — Called when Resolve is pressed.
- onReopen?: () => void — Called when the folded line is pressed to open the thread again.
- collapseAfter?: number = 3 — More replies than this and the thread shows its first and last reply with "Show N more" between them; 3 when left out.
- labels?: Partial<CommentThreadLabels> — The words it says, any of them replaced.
- Types: ThreadComment = { id: string; author: CommentAuthor; time: string; dateTime?: string; body: ReactNode; excerpt?: string; reactions?: readonly CommentReaction[] }; ReactionChoice = { emoji: string; label: string }

### ReactionBar

A row of emoji reactions with their counts, and a button to add one.

```tsx
import { ReactionBar } from '@/components/ui/goop/comment-thread';
```

### Options

- reactions?: readonly CommentReaction[] = [] — The reactions, in the order shown.
- onReact?: (reaction: ReactionChoice, reacted: boolean) => void — Called when the reader toggles a reaction (a chip, or the picker): the emoji, and whether they now react with it.
- choices?: readonly ReactionChoice[] — The emoji the picker offers; six common ones when left out.
- labels?: Partial<ReactionBarLabels> — The words it says, any of them replaced.
- Types: ReactionChoice = { emoji: string; label: string }; CommentReaction = { count: number; reacted?: boolean }; ReactionBarLabels = { reactions: string; addReaction: string; youReacted: string }

## Keyboard

- Tab: move through each comment's reaction chips and add button, then Reply and Resolve, then the replies' own
- Enter / Space: on a reaction chip: toggle the reader's reaction, the count following; on the add button: open the picker, the focus on its first emoji; on Reply: open the reply box, focused; on Resolve: fold the thread to its one line, focused, said politely; on the folded line: open it again, the focus on Resolve; on Show N more: show every reply, the focus on the first one shown
- ArrowLeft / ArrowRight / Home / End: in the picker: move along its emoji (wrapping at the ends)
- Escape: in the reply box: close it, the focus back on Reply; in the picker: close it, the focus back on the add button
- Cmd / Ctrl+Enter: in the reply box: send the reply (the composer's own key)

## Accessibility

- The part itself answers the keys above.
- active, focus-visible: the browser's own (:active, :focus-visible): write nothing
- pressed: the attribute aria-pressed
- expanded: the attribute data-state=open
- open: the attribute data-state=open

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

- [Draft email card](/themes/trail/components/draft-email-card): An email an assistant drafted, ready to send, for a page's column or a chat's reply.
- [Event proposal card](/themes/trail/components/event-proposal-card): A calendar event an assistant proposes, ready to add, for a page's column or a chat's reply.
- [Inline edit](/themes/trail/components/inline-edit): Words that read as plain text and become an editable field in place, such as a record's title or a property's value.
- [Profile card](/themes/trail/components/profile-card): A person's own page header, for an account, profile, customer or patient page.
