Threaded Comments Props
Threaded comments follow a minimal props philosophy. They work with a single prop that identifies the entity and offer optional props for specific needs.- React (Web) — one component,
ThreadedCommentSection. - React Native and Expo — three components that your screen places:
ThreadedComments,ThreadedCommentSectionandThreadedCommentInput. See React Native and Expo Components.
Component Import
- React (Web)
- React Native / Expo
Props Interface
- React (Web)
- React Native / Expo
The examples below use the web component. On React Native and Expo, pass the same props to
ThreadedComments.
Entity Identification
Provide one of these to identify which entity the comments belong to:entity
Type: Entity | undefined | null
A complete Entity object.
useFetchEntity or similar hooks.
entityId
Type: string | undefined | null
The Sublay entity’s own id (a UUID), as returned by the SDK and the API.
foreignId
Type: string | undefined | null
Your external/custom ID for the entity. The component finds the Sublay entity that has this foreignId. It creates one only when createIfNotFound is also set.
shortId
Type: string | undefined | null
A short, human-readable identifier (if you’ve set one on the entity).
You only need ONE of these props. Use whichever fits your data model best.
createIfNotFound
Type: boolean — Default: false
Used with foreignId. When set, the entity is created the first time the section is shown if no entity with that foreignId exists yet.
entity, entityId or shortId.
The other examples on this page identify the entity by entityId.
Optional Props
isVisible
Type: boolean — Default: true
React (Web) only. Whether the comment box is shown. When false, the section shows Sort by and the comments, without the box.
ThreadedCommentInput.
highlightedCommentId
Type: string | undefined | null
ID of a specific comment to highlight when the section loads. The section opens focused on that comment’s thread — its parent (if it has one) with the highlighted comment marked under it, and their replies — with a View all comments button that switches to the full comment section. If the comment doesn’t exist, the full comment section shows. See Highlighted Comments.
theme
Type: 'light' | 'dark' — Default: 'light'
Sets the color theme for the entire comment section. On React (Web) it is only for the inline styles variant. On React Native and Expo both variants use it; it goes on ThreadedComments.
- Inline Styles Variant
- Tailwind Variant
Uses the
theme prop to conditionally render dark or light colors:children
Type: React.ReactNode
Content shown in place of the “no comments yet” view, when the entity has no comments. On React Native and Expo, this is the children of ThreadedCommentSection; the children of ThreadedComments is your screen.
React Native and Expo Components
On React Native and Expo, threaded comments are three components, installed together bynpx @sublay/cli add comments-threaded --ref v8 and all exported from the component’s index.ts. Your screen places them:
KeyboardAvoidingView as above, or the keyboard library your app already uses. Give the scroll view keyboardShouldPersistTaps="handled", so tapping Reply, a vote or Sort by while the keyboard is open works on the first tap instead of only closing the keyboard.
ThreadedComments
Wraps the screen. It takes the entity props, createIfNotFound, highlightedCommentId, theme, and children: your screen, which holds ThreadedCommentSection and ThreadedCommentInput.
It holds the state the other two share, and it renders the sheets — Sort by, the comment menu, the menu for your own comment, and the report form — over the view it wraps. That view is an invisible flex: 1 view, so wrap the whole screen to have the sheets cover the screen. The navigation header your navigator draws stays outside it.
ThreadedCommentSection
The Sort by button and the comments. It has no scrolling of its own: put it inside your screen’s ScrollView, so content above it (the entity) scrolls away with the comments.
It throws an error when it is rendered outside
ThreadedComments.
ThreadedCommentInput
The comment box, with the “Replying to” bar above it. Place it anywhere inside ThreadedComments, typically pinned below the ScrollView. Tapping Reply on a comment focuses it. It never focuses itself when the screen opens.
By default, the view around the box has a top border, on the section’s background color. Passing either prop replaces that default.
ThreadedCommentInput. It throws an error when it is rendered outside ThreadedComments.
Complete Examples
Minimal Usage
foreignId with createIfNotFound instead:
With Dark Mode (Inline Styles)
With Highlighted Comment
Full Example (Web)
Full Example (React Native / Expo)
Next Steps
File Structure
Understand component organization
Features
Explore all features
Customization
Customize the component
Installation
Installation guide

