# Comments thread

Discuss one record with controlled replies, edits, deletion requests and resolved state.

Access: pro. Category: Blocks. Kind: composite.

## When to use

- Use it when a page needs discuss one record with controlled replies, edits, deletion requests and resolved state.
- Choose it inside an authenticated product surface when the host application owns routing, persistence, and service calls.

## Alternatives

- Choose empty-state instead when empty collections, search results and errors with a clear next action is the actual interface need, rather than comments thread.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Comments thread

```sh
npx shadcn@latest add @tidal-pro/comments-thread
```

Stylesheets: `components/ui/tidal.css`, `components/ui/comments-thread.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/comments-thread.css";
import{TidalCommentsThread}from"./components/ui/comments-thread";
export default()=><div className="tidal-scope"><TidalCommentsThread comments={[{id:"example",author:"value",content:"value"}]} draft={"value"} onDraftChange={() => {}} resolved={false} title={"Demo"}/></div>;
```

## Structured props

- `TidalCommentsThread.comments: ReadonlyArray<TidalThreadComment>`: Required comments value accepted by this exported component.
- `TidalCommentsThread.draft: string`: Required draft value accepted by this exported component.
- `TidalCommentsThread.onDraftChange: (value: string, event: ChangeEvent<HTMLTextAreaElement>) => void`: Callback invoked when the draft change interaction is proposed.
- `TidalCommentsThread.resolved: boolean`: Required resolved value accepted by this exported component.
- `TidalCommentsThread.title: ReactNode`: Required title value accepted by this exported component.
- `TidalCommentsThread.cancelButtonProps?: NativeButtonProps | undefined`: Optional cancel button props value accepted by this exported component.
- `TidalCommentsThread.cancelButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional cancel button ref value accepted by this exported component.
- `TidalCommentsThread.composerAttachments?: ReactNode`: Optional composer attachments value accepted by this exported component.
- `TidalCommentsThread.composerContext?: TidalCommentComposerContext | undefined` (default { kind: "comment" }): Optional composer context value accepted by this exported component.
- `TidalCommentsThread.composerError?: ReactNode`: Optional composer error value accepted by this exported component.
- `TidalCommentsThread.composerHint?: ReactNode`: Optional composer hint value accepted by this exported component.
- `TidalCommentsThread.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalCommentsThread.emptyContent?: ReactNode` (default "No comments yet."): Optional empty content value accepted by this exported component.
- `TidalCommentsThread.formProps?: (Omit<Omit<DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref">, "aria-disabled" | "children" | "dangerouslySetInnerHTML" | "onSubmit"> & { onSubmit?: (event: FormEvent<HTMLFormElement>) => void; }) | undefined`: Optional form props value accepted by this exported component.
- `TidalCommentsThread.formRef?: Ref<HTMLFormElement> | undefined`: Optional form ref value accepted by this exported component.
- `TidalCommentsThread.headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalCommentsThread.labels?: Partial<{ open: string; resolved: string; resolve: string; reopen: string; reply: string; edit: string; delete: string; comment: string; replyComposer: string; editComposer: string; submit: string; replySubmit: string; saveChanges: string; saving: string; cancel: string; actions: string; }> | undefined` (default {}): Optional labels value accepted by this exported component.
- `TidalCommentsThread.onCancelComposer?: ((event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the cancel composer interaction is proposed.
- `TidalCommentsThread.onDeleteRequest?: ((comment: TidalThreadComment, event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the delete request interaction is proposed.
- `TidalCommentsThread.onEditRequest?: ((comment: TidalThreadComment, event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the edit request interaction is proposed.
- `TidalCommentsThread.onReplyRequest?: ((comment: TidalThreadComment, event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the reply request interaction is proposed.
- `TidalCommentsThread.onResolvedChange?: ((resolved: boolean, event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the resolved change interaction is proposed.
- `TidalCommentsThread.onSubmitComment?: ((value: string, event: FormEvent<HTMLFormElement>) => void) | undefined`: Callback invoked when the submit comment interaction is proposed.
- `TidalCommentsThread.pending?: boolean | undefined` (default false): Optional pending value accepted by this exported component.
- `TidalCommentsThread.resolveButtonProps?: Omit<NativeButtonProps, "aria-pressed"> | undefined`: Optional resolve button props value accepted by this exported component.
- `TidalCommentsThread.resolveButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional resolve button ref value accepted by this exported component.
- `TidalCommentsThread.submitButtonProps?: NativeButtonProps | undefined`: Optional submit button props value accepted by this exported component.
- `TidalCommentsThread.submitButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional submit button ref value accepted by this exported component.
- `TidalCommentsThread.textareaProps?: Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "defaultValue" | "id" | "aria-disabled" | "children" | "dangerouslySetInnerHTML"> | undefined`: Optional textarea props value accepted by this exported component.
- `TidalCommentsThread.textareaRef?: Ref<HTMLTextAreaElement> | undefined`: Optional textarea ref value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/comments-thread.tsx) | [Manifest](https://tidalui.com/examples/comments-thread.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useRef, useState } from "react";

import { TidalCommentsThread, type TidalCommentComposerContext, type TidalThreadComment } from "./components/ui/comments-thread";

import "./components/ui/comments-thread.css";

function tidalExampleAvatarDataUri(seed: unknown) {
  const text = String(seed).replace(/[^a-z0-9]/gi, "").slice(-2) || "UI";
  const palette = ["#333333", "#555555", "#777777", "#999999", "#bbbbbb"];
  const color = palette[Array.from(text).reduce((sum, character) => sum + character.charCodeAt(0), 0) % palette.length];
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96"><rect width="96" height="96" rx="48" fill="${color}"/><circle cx="48" cy="38" r="17" fill="white" fill-opacity=".92"/><path d="M18 92c3-22 15-34 30-34s27 12 30 34" fill="white" fill-opacity=".92"/></svg>`;
  return `data:image/svg+xml,${encodeURIComponent(svg)}`;
}

function tidalExampleImageDataUri(label: string) {
  const safeLabel = label.replace(/[<>&]/g, "").slice(0, 28) || "Sample image";
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 675"><defs><linearGradient id="g" x1="0" x2="1" y1="0" y2="1"><stop stop-color="#171717"/><stop offset="1" stop-color="#555555"/></linearGradient></defs><rect width="1200" height="675" fill="url(#g)"/><circle cx="950" cy="100" r="260" fill="white" fill-opacity=".08"/><text x="80" y="570" fill="white" font-family="system-ui,sans-serif" font-size="64" font-weight="700">${safeLabel}</text></svg>`;
  return `data:image/svg+xml,${encodeURIComponent(svg)}`;
}

const tidalExampleStyles = ".tidal-scope .comments-thread-demo {\n  container: comments-thread-demo / inline-size;\n  display: grid;\n  width: 100%;\n  max-width: 760px;\n  min-width: 0;\n  gap: 12px;\n}\n\n.tidal-scope .comments-thread-demo-footer {\n  display: flex;\n  min-width: 0;\n  align-items: center;\n  justify-content: space-between;\n  gap: 12px;\n  flex-wrap: wrap;\n}\n\n.tidal-scope .comments-thread-demo-footer p {\n  min-width: 0;\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .comments-thread-demo-footer button {\n  min-width: 44px;\n  min-height: 44px;\n  max-width: 100%;\n  padding: 9px 12px;\n  color: var(--t-ink);\n  background: var(--t-surface);\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-control);\n  font: inherit;\n  font-size: 11px;\n  font-weight: 650;\n  line-height: 1.3;\n  overflow-wrap: anywhere;\n  cursor: pointer;\n}\n\n.tidal-scope .comments-thread-demo-footer button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n\n@container comments-thread-demo (max-width: 360px) {\n  .tidal-scope .comments-thread-demo-footer {\n    align-items: stretch;\n    flex-direction: column;\n  }\n}";

const initialComments: TidalThreadComment[] = [
  {
    id: "ava-review",
    author: "Ava Reed",
    avatar: <img src={tidalExampleAvatarDataUri("01")} alt="" />,
    timestamp: "10:18 AM",
    dateTime: "2026-10-14T10:18:00-05:00",
    content:
      "The launch note is clear. Could we name the owner for the final accessibility check?",
    attachments: <span>launch-notes.pdf · sample attachment</span>,
    actions: {
      reply: {},
    },
  },
  {
    id: "noah-reply",
    author: "Noah Kim",
    avatar: <img src={tidalExampleAvatarDataUri("02")} alt="" />,
    timestamp: "10:24 AM",
    dateTime: "2026-10-14T10:24:00-05:00",
    replyToLabel: "Reply to Ava",
    content: "I can own that check and add the result here before noon.",
    actions: {
      reply: {},
      edit: {},
      delete: {},
    },
  },
  {
    id: "mila-note",
    author: "Mila Chen",
    avatar: <img src={tidalExampleAvatarDataUri("03")} alt="" />,
    timestamp: "10:31 AM",
    dateTime: "2026-10-14T10:31:00-05:00",
    content: "@Noah I added the mobile checklist to the sample brief.",
    actions: {
      reply: {},
    },
  },
];

const baseContext: TidalCommentComposerContext = { kind: "comment" };

export function CommentsThreadDemo() {
  const [comments, setComments] = useState(initialComments);
  const [resolved, setResolved] = useState(false);
  const [draft, setDraft] = useState("");
  const [context, setContext] =
    useState<TidalCommentComposerContext>(baseContext);
  const [status, setStatus] = useState(
    "Local sample discussion. Nothing is sent or stored.",
  );
  const nextId = useRef(1);

  const cancelComposer = () => {
    setDraft("");
    setContext(baseContext);
  };

  return (
    <div className="comments-thread-demo">
      <TidalCommentsThread
        title="Launch brief comments"
        description="Review notes for this sample record."
        comments={comments}
        resolved={resolved}
        onResolvedChange={(next) => {
          setResolved(next);
          setStatus(
            next ? "Sample thread resolved." : "Sample thread reopened.",
          );
        }}
        onReplyRequest={(comment) => {
          setDraft("");
          setContext({
            kind: "reply",
            commentId: comment.id,
            label: `Reply to ${comment.author}`,
          });
        }}
        onEditRequest={(comment) => {
          setDraft(typeof comment.content === "string" ? comment.content : "");
          setContext({
            kind: "edit",
            commentId: comment.id,
            label: `Edit ${comment.author}'s comment`,
          });
        }}
        onDeleteRequest={(comment) => {
          setComments((current) =>
            current.filter((candidate) => candidate.id !== comment.id),
          );
          if (context.kind !== "comment" && context.commentId === comment.id) {
            cancelComposer();
          }
          setStatus(`${comment.author}'s sample comment deleted.`);
        }}
        draft={draft}
        onDraftChange={setDraft}
        composerContext={context}
        onCancelComposer={cancelComposer}
        composerHint="Use this local form to add, reply to, or edit a sample comment."
        textareaProps={{
          placeholder: "Write a comment",
          maxLength: 500,
          autoComplete: "off",
        }}
        onSubmitComment={(value, event) => {
          event.preventDefault();
          const message = value.trim();
          if (!message) return;
          if (context.kind === "edit") {
            setComments((current) =>
              current.map((comment) =>
                comment.id === context.commentId
                  ? { ...comment, content: message, editedLabel: "Edited" }
                  : comment,
              ),
            );
            setStatus("Sample comment edited.");
          } else {
            const target =
              context.kind === "reply"
                ? comments.find((comment) => comment.id === context.commentId)
                : undefined;
            setComments((current) => [
              ...current,
              {
                id: `local-${nextId.current++}`,
                author: "You",
                avatar: <span aria-hidden="true">YS</span>,
                timestamp: "Just now",
                replyToLabel: target ? `Reply to ${target.author}` : undefined,
                content: message,
                actions: { edit: {}, delete: {} },
              },
            ]);
            setStatus(target ? "Sample reply added." : "Sample comment added.");
          }
          setDraft("");
          setContext(baseContext);
        }}
      />
      <footer className="comments-thread-demo-footer">
        <p role="status">{status}</p>
        <button
          type="button"
          onClick={() => {
            setComments(initialComments);
            setResolved(false);
            cancelComposer();
            setStatus("Sample discussion reset.");
          }}
        >
          Reset sample
        </button>
      </footer>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <CommentsThreadDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Consumer-owned comments require unique IDs, author names and ReactNode content. Optional avatar, timestamp/dateTime, edited label, reply relationship, attachment slot, and explicit per-comment Reply/Edit/Delete action configs support native button props/refs. Controlled resolved state and onResolvedChange expose a native toggle action. The controlled native composer supports comment/reply/edit context, draft proposal, native form action/method/submitter overrides, form and textarea props/refs, caller-first prevention, hint/error/attachment slots, pending state and synchronous accepted-action focus recovery. Root native section attributes/ref, bounded headingLevel, numeric/nullish slots, empty content and labels are supported. Consumers own authorization, content safety, comment state, mentions, uploads, confirmation, transport and persistence. The component performs no request or storage operation.
