Comment Thread

Comments with replies, @mentions, an AI participant, edit, delete and resolve.

PROGet Comment Thread and 168 other Pro components with pro lifetime — Get Pro

Category
Workspace
Access
Pro
Source
739 lines · one file
States
7 drawn

The decision inside it

An agent's reply always says AI

A model's comment is marked AI next to its name, never only by its avatar, so people always know which replies a person wrote.

When to use it

Use Comment Thread for discussion pinned to one thing (a clause, a cell, a frame) with replies, @mentions and resolve. Use CommentsPanel beside a document to list every thread with Open, Resolved and Mine filters. For a chat between people and an agent, use the chat components.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Comment Thread for this.
Install it: npx shadcn@latest add @liro/comment-thread
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/comment-thread.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/clause-comments.tsx
import { CommentThread, type Comment } from "@/components/ui/comment-thread";

export function ClauseComments({ comments, reply, resolve }: { comments: Comment[]; reply: (body: string) => void; resolve: (done: boolean) => void }) {
  return (
    <CommentThread
      anchor="Clause 4.2"
      comments={comments}
      currentUserId="michael"
      mentionable={[{ id: "olivia", name: "Olivia Martinez" }, { id: "sarah", name: "Sarah Anderson" }]}
      onReply={reply}
      onResolve={resolve}
    />
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
commentsComment[] YesOldest first. The first comment opens the thread.
resolvedboolean NoFolded to the first comment with a "Resolved" summary.
mentionableMentionablePerson[] NoWho @ can mention.
currentUserIdstring NoYou, for Edit and Delete on your own comments.
anchorstring NoWhat the thread is attached to, shown above it ("Clause 4.2").
onReply(body: string) => void NoSend a reply. Without it there is no reply box.
onResolve(resolved: boolean) => void NoResolve (true) or reopen (false). Without it there is no Resolve button.
onEdit(id: string, body: string) => void NoSave an edited comment.
onDelete(id: string) => void NoDelete a comment.
lookLook NoLayered rests the thread in a tray with Resolve in the strip below. Default layered.
placeholderstring NoThe reply box's placeholder. Default "Reply…".

Dependencies

npm packages

clsxlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-themeavatar-stack

States

All of them are drawn by the component. None is left for you to design.

  • Open
  • Replying
  • Mentioning
  • Editing
  • Deleting
  • Resolved
  • Panel

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances