Skip to content
Calm motion: animations on this site only fade, with no movement

Thread ​

Nested comment thread

Comments with replies, and replies to those replies, as under an issue, a document, or a post. Each comment is a Message. For a chat that runs in one line, use Message and MessageScroller.

Basic
  1. Megumi Kato
    The route draft is ready. Can you check the second day?
    3 replies
    1. Tomoya Aki
      The museum closes at five. We need to go there first.
      1 reply
      1. Megumi Kato
        Done. I moved lunch to the afternoon.
    2. Eriri Spencer
      I can draw the map.
  2. Utaha Kasumigaoka
    Notes on the ending are in the shared folder.
    1 reply
    1. Michiru Hyodo
      Read them. Agreed.
  • comments is a list of { id, name, avatar, time, datetime, body, replies }. replies has the same shape, to any depth.
  • The replies of a comment are in a native <details>. Its summary counts all the replies below, for example "3 replies". A click or Enter folds them. collapsed: true on a comment starts its replies folded.
  • A line under the avatar joins the replies to their parent. Below maxDepth (default 3), the replies stop indenting, so a long chain stays readable on a phone.
  • body is plain text. For links, mentions, or code, use the default slot. The slots default, footer, and actions get { comment, depth } on every level. Put the Reply button in footer.
  • The thread is a nested ordered list, so a screen reader announces the number of comments on each level.
  • Change the words with labels.replies or a label pack.

Usage ​

ts
import { BlessThread } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
comments*BlessThreadComment[]—
maxDepthnumber3replies deeper than this stop indenting, so a long chain stays readable on a phone
labelsPartial<{ replies: (n: number) => string; }>—
depthnumber0

Slots

NameScopeDescription
default{ comment: BlessThreadComment; depth: number; }
footer{ comment: BlessThreadComment; depth: number; }
actions{ comment: BlessThreadComment; depth: number; }

Released under the MIT License. Character names and artwork belong to their owners.