CommentThread

A conversation that reads as one. Replies hang off a thin rail and fold away, likes count as they change, and the reply box opens in place and grows as you type. Cards.

Open playground
  • Alex2h ago

    This is sample discussion content. Replies hang off a thin rail under their parent.

    • Sam1h ago

      Fold the replies away with the button below, or add one of your own.

    • Jo40m ago

      Cmd or Ctrl plus Enter posts from the box.

  • RileyJust now

    A second top-level comment, with no replies yet.

About

CommentThread is a React component in the Cards category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { CommentThread } from "@ashutoshswamy/smoui" and set onLike, comments[].likes, comments among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { CommentThread } from "@ashutoshswamy/smoui";

<CommentThread comments={comments} onReply={(parentId, body) => saveReply(parentId, body)} />

Props 4

onLike

Adds a like button with a rolling count on each comment.

(id, on) => void
comments[].likes

Starting like count.

number
comments

Comments with optional nested replies.

CommentItem[]
onReply

Enables the reply composer; update comments in the parent.

(parentId: string, body: string) => void