BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/ilinxa/comment-thread

Comment Thread

ilinxa/comment-thread
FreeBlock

Recursive comment thread with composer, optimistic add, like, and delete, inline expansion past max depth, and realtime subscription hooks.

Install it

npx shadcn@latest add https://ui.ilinxa.com/r/comment-thread.json

Source

src/registry/components/data/comment-thread/comment-thread.tsxui.ilinxa.com/r/comment-thread.json · first 6 KB
1"use client";
2
3import {
4 memo,
5 useCallback,
6 useEffect,
7 useImperativeHandle,
8 useMemo,
9 useRef,
10 useState,
11} from "react";
12import { cn } from "@/lib/utils";
13import {
14 DEFAULT_COMMENT_THREAD_LABELS,
15 type Comment,
16 type CommentThreadHandle,
17 type CommentThreadProps,
18 type CommentThreadLabels,
19} from "./types";
20import { useCommentState } from "./hooks/use-comment-state";
21import { CommentNode } from "./parts/comment-node";
22import {
23 CommentComposer,
24 type CommentComposerHandle,
25} from "./parts/comment-composer";
26import { CommentEmptyState } from "./parts/comment-empty-state";
27import { defaultRelativeTime } from "./lib/format-time";
28
29interface CommentThreadInnerProps extends CommentThreadProps {
30 ref?: React.Ref<CommentThreadHandle>;
31}
32
33function genTempId(): string {
34 if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
35 return `temp-${crypto.randomUUID()}`;
36 }
37 return `temp-${Date.now()}-${Math.random().toString(36).slice(2)}`;
38}
39
40function CommentThreadInner(props: CommentThreadInnerProps) {
41 const {
42 comments: initialComments,
43 variant = "default",
44 currentUser,
45 maxDepth = 2,
46 indentPx = 24,
47 bodyMaxLines: bodyMaxLinesProp,
48 composerMinRows = 1,
49 composerMaxRows = 6,
50 submitOnEnter = true,
51 pageSize = 10,
52 subscribe,
53 onSubscribeDelta,
54 onAddComment,
55 onLikeComment,
56 onDeleteComment,
57 onReportComment,
58 onLoadMore,
59 commentActions,
60 renderNode,
61 renderViewReplies,
62 renderComposer,
63 composerEmptyState,
64 emptyState,
65 labels: labelsProp,
66 className,
67 composerClassName,
68 nodeClassName,
69 ref,
70 } = props;
71
72 const bodyMaxLines = bodyMaxLinesProp ?? (variant === "compact" ? 2 : 4);
73
74 const labels = useMemo<
75 Required<Omit<CommentThreadLabels, "formatRelativeTime">>
76 >(
77 () => ({ ...DEFAULT_COMMENT_THREAD_LABELS, ...labelsProp }),
78 [labelsProp],
79 );
80
81 const format = useMemo(
82 () => labelsProp?.formatRelativeTime ?? defaultRelativeTime,
83 [labelsProp?.formatRelativeTime],
84 );
85
86 const { comments, dispatch } = useCommentState({
87 initialComments,
88 subscribe,
89 onSubscribeDelta,
90 });
91
92 const [replyParentId, setReplyParentId] = useState<string | null>(null);
93 const replyTriggerRef = useRef<HTMLElement | null>(null);
94 const [currentPage, setCurrentPage] = useState(1);
95 const [isLoadingMore, setIsLoadingMore] = useState(false);
96 const [hasMore, setHasMore] = useState(initialComments.length === pageSize);
97// … truncated

What it pulls in

npm packages

  • lucide-react

Other registry items

  • @ilinxa/expandable-text
  • @ilinxa/engagement-bar
  • avatar
  • button
  • dropdown-menu
  • textarea

Files it writes

  • src/registry/components/data/comment-thread/comment-thread.tsx
  • src/registry/components/data/comment-thread/index.ts
  • src/registry/components/data/comment-thread/types.ts
  • src/registry/components/data/comment-thread/parts/comment-node.tsx
  • src/registry/components/data/comment-thread/parts/comment-composer.tsx
  • src/registry/components/data/comment-thread/parts/comment-kebab.tsx
  • src/registry/components/data/comment-thread/parts/view-replies-link.tsx
  • src/registry/components/data/comment-thread/parts/comment-empty-state.tsx
  • src/registry/components/data/comment-thread/hooks/use-comment-state.ts
  • src/registry/components/data/comment-thread/hooks/use-autosize-textarea.ts
  • src/registry/components/data/comment-thread/lib/format-time.ts

Facts

Registry
ilinxa
Type
registry:block
Access
Free
Files written
11
Licence
MIT
In the index
at or before 2026-08-13
Last confirmed
today

Go to the source

ui.ilinxa.com ilinxa/pro-ui on GitHub Raw registry item This item as JSON

More from ilinxa

All 184 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Account Switcheraccount-switcherilinxaBlocksFree1 dep · 10 files
Account Switcher (deprecated alias)account-switcher-01ilinxaBlocksFreeno deps
Account Switcher — fixturesaccount-switcher-fixturesilinxaBlocksFreeno deps
App Sidebarapp-sidebarilinxaBlocksFree1 dep · 37 files
App Sidebar — fixturesapp-sidebar-fixturesilinxaBlocksFreeno deps
Rich Text Editor (deprecated alias)article-body-01ilinxaBlocksFreeno deps
Article Metaarticle-metailinxaBlocksFree1 dep · 4 files
Article Meta (deprecated alias)article-meta-01ilinxaBlocksFreeno deps
BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex

BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex

BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex