Threaded Comments Features
Comprehensive feature overview for Reddit-style threaded comments.Core Features
Layout
The section has no scrolling of its own. It is as tall as its comments, and the page or screen it sits in scrolls, so the entity above it scrolls away with the comments.- React (Web) — one component: the comment box at the top, then Sort by, then the comments. It has no fixed height; the page scrolls.
- React Native and Expo — three components that your screen places.
ThreadedCommentswraps the screen and renders the sheets over it.ThreadedCommentSection(Sort by and the comments) goes inside your screen’sScrollView.ThreadedCommentInput(the comment box) goes anywhere insideThreadedComments, typically pinned below theScrollView. Keyboard handling is up to your screen. See React Native and Expo Components.
Unlimited Nesting
Comments can be nested infinitely deep. Users can reply to any comment, creating branching conversation threads.Replying
Every comment has a Reply button. A reply is nested under the exact comment it answers, at any depth. Where the reply is written depends on the platform:- React (Web) — Reply opens a reply box under the comment. Cancel closes it. @ mention suggestions work in the reply box as they do in the comment box, and open below the box so they don’t cover the comment being replied to. The author being replied to is not mentioned automatically.
- React Native and Expo — replies are written in the comment box,
ThreadedCommentInput, wherever your screen places it. Reply makes that comment the one being replied to and focuses the input, so the keyboard opens. The input never focuses itself when the screen opens. A “Replying to” bar appears above the input, with the author’s avatar and name and a cancel button on the right. The comment being replied to is marked in the list the same way as a highlighted comment. Tapping Reply on the same comment again, or the bar’s cancel button, cancels the reply, and the input posts top-level comments again. Tapping Reply on another comment switches to that comment.
reply-banner/reply-banner.tsx. The Reply button’s behavior is handleReplyPress in single-comment.tsx, and focusCommentInput in context/ui-state-context.tsx focuses the input.
Sending a Comment
- React (Web) — the comment box sits above the comments. It starts as a one-line box; clicking it opens it, and it grows with the text and shows the GIF button (when GIFs are enabled), Cancel and Post. Cancel clears the text and folds the box back to one line, and so does posting. Enter posts and Shift+Enter adds a line break, in the comment box and in the reply box under a comment. @ mention suggestions open below the comment box. The box is
new-comment-form.tsx, and its place above the comments is set inthreaded-comment-section.tsx. - React Native and Expo — the send button posts the comment. Return adds a line break.
Sorting
The section opens on Top. The options are:- Top — most upvoted comments first (ranked by the number of upvotes, not upvotes minus downvotes)
- New — newest comments first
- Old — oldest comments first
- Controversial — comments with many upvotes and downvotes and a close split first
- React (Web) — a Sort by dropdown sits between the comment box and the comments. The options are listed at the top of
sort-by-dropdown.tsx; remove an entry to drop that option. - React Native and Expo — a Sort by: Top button sits above the comments. Tapping it opens a Sort comments by sheet with the four options and a check mark on the current one. The options are listed in
utils/sort-options.ts; remove an entry to drop that option. The button issort-by-trigger/sort-by-trigger.tsxand the sheet issheets/sort-sheet.tsx.
Loading Replies
The section loads its first screen in a single request: 10 top-level comments, each with up to 3 replies, 2 levels deep.- More replies — when a comment has replies that aren’t shown, a “N more replies” button loads them in place. That covers replies beyond the ones listed, and replies of comments below the second level, which the first screen doesn’t bring; those load with a few levels of nesting again. Indentation stops growing after 6 levels.
- Load more comments — a button under the list loads the next top-level comments.
repliesCount; whether a “more” button shows is driven by hasMore. To change how much loads up front, edit limit, replyDepth and replyLimit in providerProps in hooks/use-threaded-comments.tsx.
Blocked Users
When themoderation bundle is installed, comments involving a block render as compact rows instead of disappearing, so the replies under them stay in place:
- “This comment is unavailable” — the comment’s author blocked the user. No author, content, reply or reaction controls are shown. If the user had reacted before, they can still remove their reaction.
- “Comment from a user you blocked” — the user blocked this author. The row starts collapsed with a Show anyway button; once shown, the comment can be replied to and reacted to as usual.
single-comment.tsx. See Comment → Blocked authors for the underlying flags.
Deleted & Removed Comments
A comment its author deleted shows[deleted] in place of the author name and the text; a comment a moderator removed shows [removed]. The row has no reply, reaction or menu controls, and the replies under it stay in place — and can still be replied to. The author of a removed comment still sees it in full, with a muted note under the text — Removed by a moderator · only you can see this, or Removed by a moderator: <reason> · only you can see this when the moderator gave a reason. Their row keeps delete, but has no Reply or vote buttons, since the server refuses both. A comment whose author blocked the user shows as “This comment is unavailable” instead, even when it is also deleted or removed.
Edit the row text in single-comment.tsx. See Comment → Placeholders for the underlying fields.
Upvote/Downvote System
Reddit-style voting with visible vote scores.- Upvote and downvote buttons (an up and a down chevron)
- Net score display (upvotes − downvotes)
- Visual feedback on current vote state
- One vote per user per comment
- Change or remove vote at any time
- Can’t vote on your own comments
Visual Threading
Clear visual hierarchy with indentation and connection lines.- Each reply level is indented by 24px, up to 6 levels; deeper replies stay in one column
- One continuous line runs from under a comment’s avatar down to its last reply, with a rounded elbow into each reply’s avatar
- The “N more replies” row hangs from the same line, and so does the reply box on React
- Collapsing a thread removes its lines along with its replies
indentation-threading-lines.tsx. Every line is derived from them, so changing one keeps the joins intact:
The line color is set in the same file.
Collapsible Threads
Users can collapse a comment and everything under it, at any depth.- React (Web) — a comment with replies has a ⊖ circle on its line, level with its Reply and vote buttons. Hovering the line, the circle, or the elbow into any of its direct replies highlights that whole line (white in dark mode, near-black in light); clicking any of them collapses the comment. A collapsed comment is a single row: a ⊕ in place of the avatar, then the name, the time and the start of its text, cut to fit, with its replies hidden. Clicking the row or the ⊕ expands it. The line pieces, the hit areas and the circle are in
indentation-threading-lines.tsx; each comment’s hover state is incomment-thread.tsx. - React Native and Expo — tap the comment itself. It shrinks to a single row, avatar, name, time and the start of its text, cut off to fit, and its replies are hidden. Tap the row again to expand it. The avatar, the name, the votes, Reply, the menu and mention links keep their own taps. With a screen reader (VoiceOver, TalkBack), the comment’s text offers it as an action: double-tap it, or choose Collapse thread / Expand thread from its actions. Collapsing and expanding slide the comments below into place (a Reanimated layout transition,
COLLAPSE_TRANSITIONincomment-thread.tsx); the replies hide and show at once. The row is insingle-comment.tsxand the collapsed state incomment-thread.tsx.
@ Mentions
Tag other users with@username.
- Autocomplete suggestions as you type
- Clickable mentions link to user profiles (via
otherUserClickCallback) - Mentioned users receive notifications (if enabled)
- Works in both comments and replies
- On React Native and Expo, the suggestions open as a full-width panel at the top of the comment box, above the “Replying to” bar: the box grows upward to hold them (the server returns at most 5)
Highlighted Comments
Deep-link to a specific comment and open the section focused on its thread.- The highlighted comment’s parent at the top, with the highlighted comment under it marked: a subtle background across its whole row, a blue tint on the indentation beside it, and a blue connector line leading into it. A top-level comment is shown on its own, as the top of the thread.
- The normal replies machinery under them — “N more replies”, voting, replying and deleting work as everywhere else in the section.
- A View all comments button above the thread. It switches to the full comment section: the regular thread from the top, loaded as usual. The highlighted comment is marked there when it is among the loaded comments; a comment deeper in the thread, or further down the list, shows once its thread is loaded. Opening the link again returns to the focused view. Posting a new top-level comment from the focused view switches to the full section too, so the new comment is visible; replies posted inside the focused thread keep the focused view.
?commentId=abc123.
Delete
Comment authors can delete their own comments. Delete: Click “Remove” in the comment menu (“Delete” on React Native), then confirm. The comment shows as[deleted], keeping its replies in place.
Reporting & Moderation
Built-in reporting for inappropriate content. Users: Click “Report” → select reason → submit. Admins: Reports appear in the Sublay Dashboard for review. Full moderation toolkit including comment deletion and user banning.Loading States
Skeleton loaders while fetching comments. Realistic skeleton UI mimics comment structure and prevents layout shift. File:fetching-comments-skeletons.tsx
Empty States
Friendly placeholder when no comments exist yet. Default message: “No comments yet” with “Start the conversation.” under it. Customizeno-comments-placeholder.tsx to change messaging or add illustrations.
Error States
When a load fails, the component shows a retry instead of a wrong or stuck state:- First load fails — “Couldn’t load comments” with a Try again button, in place of the empty state.
- The entity can’t be loaded — the same “Couldn’t load comments” with Try again. This is the case when the section looks the entity up from
entityId,foreignIdorshortIdand the lookup fails or finds nothing. AforeignIdthat has no entity yet finds nothing unless the section is givencreateIfNotFound. - “Load more comments” fails — “Couldn’t load more · Try again” in place of the button.
- “N more replies” fails — the same “Couldn’t load more · Try again” in place of that button, including inside the focused thread view.
loadMore() that failed, which re-sends the failed request. When the entity couldn’t be loaded, it looks the entity up again first, and the comments load once it is found. Edit the text in comments-feed.tsx and comment-thread/comment-replies.tsx.
When posting fails, a short muted message appears by the form that was used. On React that is under the comment form, or under the reply box. On React Native and Expo, where comments and replies are both written in the comment box, it is above that box:
- Replying to a comment that was deleted in the meantime — “This comment was deleted, so you can’t reply to it.”
- Replying to a comment a moderator removed in the meantime — “This comment was removed, so you can’t reply to it.”
- Any other failure — “Couldn’t post your comment. Try again.”
[deleted] / [removed] row (or, for its author, the removed-note row), which has no Reply. On React the reply box closes and the message shows on that row until the next comment is sent. On React Native and Expo the “Replying to” bar goes away, the message shows above the input, and the text stays in the input, which posts top-level comments again.
The messages are chosen in utils/comment-create-error.ts, worded in utils/strings.ts, and come from the section’s createError. On React they are rendered in new-comment-form.tsx, comment-thread/new-reply-form.tsx and single-comment.tsx; on React Native and Expo, in new-comment-form.tsx.
Real-Time Updates
Comments automatically update when other users post. No configuration needed — powered by@sublay/react-js subscriptions.
Dark Mode Support
Inline Styles Variant:theme the same way as the inline styles variant.
All colors adapt automatically.
GIF Support (Optional)
GIFs come from Giphy and need a Giphy API key, read from your app’s environment. The key is read inutils/env.ts, inside the component’s folder, which add writes for your framework (it looks for next, vite or react-scripts in your package.json):
To use a different variable, change its name in
utils/env.ts. Without a key, the GIF button shows only in development, and clicking it shows an alert naming the variable to set. In production the button is hidden until there is a key (on other web frameworks, once isDevelopment in utils/env.ts reads your framework’s development flag).
The GIF picker always covers the whole screen: on React (Web) it covers the browser window, and on React Native and Expo it opens in a Modal. See GIF Picker Placement.
Feature Matrix
Next Steps
Customization
Learn how to customize features
Props & API
Component props reference
File Structure
Understand file organization
Installation
Installation guide

