Skip to main content

Social Comments Props

The SocialCommentSection component follows the same minimal props philosophy as all Sublay components. It works with a single prop that identifies the entity and offers optional props for specific needs.

Component Import


Props Interface


Entity Identification

Provide one of these to identify which entity the comments belong to:

entity

Type: Entity | undefined | null A complete Entity object. Use when you already have it from 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.
Without it, the section only finds an existing entity. When there is none, it shows its “Couldn’t load comments” state instead of the comments. The created entity has no author, so the project’s Who can create entities without an author setting decides who may create it. The default, Everyone, lets any visitor’s section create it. Under Signed-in users only a visitor with no session can’t, and under No one from the client only a service key can (create the entity from your backend first). A refused section shows the same “Couldn’t load comments” state. See Fetch Entity by Foreign ID. It has no effect with entity, entityId or shortId. The other examples on this page identify the entity by entityId.

Optional Props

isVisible

Type: boolean — Default: true Controls whether the comment section is visible. Useful when rendering inside a modal, drawer, or bottom sheet.

highlightedCommentId

Type: string | undefined | null ID of a specific comment to highlight on load. Once it loads, the component shows it at the top of the list with a highlight background color: a top-level comment on its own, or a reply under its parent comment, visible even while the parent’s other replies are collapsed. The rest of the comments follow below, without repeating it. If the comment doesn’t exist, the list shows as usual.

gifPickerFullScreen

Type: boolean — Default: false Where the GIF picker opens, on React, React Native and Expo. By default it covers the comment section: the comment list and the form. When set, it covers the whole screen. On React Native and Expo the full-screen picker opens in a Modal, so it covers the screen wherever the section sits in your app, and Android’s back button closes it.
See GIF Picker Placement for custom layouts.

theme

Type: 'light' | 'dark' — Default: 'light' Sets the color theme for the component: in both variants on React Native and Expo, and in the inline styles variant on React. The Tailwind variant on React ignores it.

children

Type: React.ReactNode Optional content rendered within the comment section.

Usage Examples

Minimal

For a record in your own database, use foreignId with createIfNotFound instead:

With Dark Mode (Inline Styles)


With Highlighted Comment


In a React Native Bottom Sheet


Next Steps

File Structure

Component organization

Features

Feature overview

Customization

Customize the component

Installation

Installation guide