# Comment thread

- **[App UI](/app/)**
- **[Comments](/app/comments/)**
- **Comment thread**

A discussion between people: comments with author and time, replies one level deep, a Reply button that opens a form under its comment (focus moves in and back), and a…

## Notes

- **When to use it**: A discussion under a record: comments with replies one level deep and a field to write a new one. For a conversation with an assistant use `app-assistant-thread`; for a notification feed use `app-notifications-inbox`.
- **Writing for it**: - Use 1 to 4 top-level comments with up to 3 replies each. Give every comment an author and time so the replies make sense without extra context.
- `replyLabel` (20) is followed by the author's name for screen readers, so use just Reply rather than Reply to this comment.
- `composer.empty` (80) is shown when someone posts an empty field. Say what to write, not that the field is invalid.
- **Watch out for**: What a person posts lives only in this block and is not saved, and it starts over when the thread props change. Replies cannot be nested further, so a reply form on a reply is not offered.

## Pairs well with

- **[App, notification inbox](/blocks/app/notifications-inbox)**
- **[App, kanban board](/blocks/app/boards-kanban)**
- **[App, member list](/blocks/app/team-members)**

## Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx

```
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import AppCommentsThread from '@/components/klarhimmel/blocks/app-comments-thread';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <AppCommentsThread props={{
          "eyebrow": "Discussion",
          "title": "Name the discussion",
          "description": "Say who can see this.",
          "summaryWord": "comments",
          "comments": [
            {
              "author": "Person one",
              "time": "0 hours ago",
              "body": "Write a comment of one or two sentences, with a question for the team.",
              "replies": [
                {
                  "author": "Person two",
                  "time": "0 hour ago",
                  "body": "Write a short reply to the comment."
                }
              ]
            }
          ],
          "replyLabel": "Reply",
          "replyForm": {
            "label": "Your reply",
            "submit": "Send reply",
            "cancel": "Cancel"
          },
          "composer": {
            "label": "Add a comment",
            "submit": "Post comment",
            "posting": "Posting…",
            "empty": "Say to write something first."
          },
          "you": "You",
          "justNow": "just now",
          "notices": {
            "posted": "Comment posted.",
            "replied": "Reply posted."
          },
          "state": "filled",
          "messages": {
            "emptyTitle": "No comments yet",
            "emptyBody": "Say what starting the discussion does.",
            "error": "Say the post failed and to retry."
          }
        }} />
      </BlockSurface>
    </Theme>
  );
}
```

## Props

The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.

- **eyebrow**: Text, up to 60 characters. Optional; empty is not rendered.
- **title**: Text, up to 120 characters.
- **description**: Text, up to 300 characters. Optional; empty is not rendered.
- **summaryWord**: Text, up to 20 characters.
- **comments**: List of 1 to 4. Each item: author, time, body, replies.
- **replyLabel**: Text, up to 20 characters.
- **replyForm**: Fields: label, submit, cancel.
- **composer**: Fields: label, submit, posting, empty.
- **you**: Text, up to 24 characters.
- **justNow**: Text, up to 24 characters.
- **notices**: Fields: posted, replied.
- **state**: One of 'filled', 'empty', 'posting', 'error'.
- **messages**: Fields: emptyTitle, emptyBody, error.
- **headingLevel**: One of '1', '2'. Optional; empty is not rendered.

## Install

- **CLI**

  ```
  npx shadcn add @klarhimmel/app-comments-thread
  ```

Uses

- Avatar
- Banner
- Button
- Textarea
- EmptyState

- **About**: A discussion between people: comments with author and time, replies one level deep, a Reply button that opens a form under its comment (focus moves in and back), and a composer.
- **States**: Filled, empty, posting and error. Reply opens a form under its comment and names the author; Escape closes it. New project? Set it up once: /get-started/installation.
