> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Social Comments Props

> SocialCommentSection props and API

# 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

```tsx theme={null}
import { SocialCommentSection } from './components/comments-social';
```

***

## Props Interface

```tsx theme={null}
interface SocialCommentSectionProps {
  // Entity identification (provide ONE of these)
  entity?: Entity | undefined | null;
  entityId?: string | undefined | null;
  foreignId?: string | undefined | null;
  shortId?: string | undefined | null;

  // With foreignId: create the entity if it doesn't exist yet
  createIfNotFound?: boolean;

  // Optional features
  isVisible?: boolean;
  highlightedCommentId?: string | undefined | null;
  gifPickerFullScreen?: boolean;
  theme?: 'light' | 'dark';   // Not used by the Tailwind variant on React
  children?: React.ReactNode;
}
```

***

## 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`](#createifnotfound) is also set.

### `shortId`

**Type:** `string | undefined | null`

A short, human-readable identifier if you've set one on the entity.

> [!NOTE]
>
> **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.

```tsx theme={null}
<SocialCommentSection foreignId="photo_123" createIfNotFound />
```

Without it, the section only finds an existing entity. When there is none, it shows its ["Couldn't load comments" state](https://docs.sublay.io/v8/components/components/social/features.md#error-states) 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](https://docs.sublay.io/v8/api-reference/entities/fetch-entity-by-foreign-id.md).

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.

```tsx theme={null}
<SocialCommentSection
  entityId={entity.id}
  isVisible={showComments}
/>
```

***

### `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.

```tsx theme={null}
<SocialCommentSection
  entityId={entity.id}
  highlightedCommentId="comment_456"
/>
```

***

### `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.

```tsx theme={null}
<SocialCommentSection
  entityId={entity.id}
  gifPickerFullScreen
/>
```

See [GIF Picker Placement](https://docs.sublay.io/v8/components/customization/layout-structure.md#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.

> [tab] Inline Styles Variant
>
> ```tsx theme={null}
> <SocialCommentSection
>   entityId={entity.id}
>   theme={isDark ? 'dark' : 'light'}
> />
> ```

> [tab] Tailwind Variant
>
> **React Native and Expo:** pass `theme` as above. Each class is chosen from it in code; there is no Tailwind dark mode setup.
>
> **React:** ignores this prop. Use Tailwind's dark mode system instead:
>
> ```tsx theme={null}
> <html className={isDark ? 'dark' : ''}>
>   <SocialCommentSection entityId={entity.id} />
> </html>
> ```
>
> Requires Tailwind's dark mode to follow the `dark` class: `darkMode: 'class'` in `tailwind.config.js` (Tailwind CSS 3), or `@custom-variant dark (&:where(.dark, .dark *));` in your CSS (Tailwind CSS 4).

***

### `children`

**Type:** `React.ReactNode`

Optional content rendered within the comment section.

```tsx theme={null}
<SocialCommentSection entityId={entity.id}>
  <div className="text-center text-gray-400 text-sm my-2">
    Share your thoughts!
  </div>
</SocialCommentSection>
```

***

## Usage Examples

### Minimal

```tsx theme={null}
<SocialCommentSection entityId={entity.id} />
```

For a record in your own database, use [`foreignId`](#foreignid) with [`createIfNotFound`](#createifnotfound) instead:

```tsx theme={null}
<SocialCommentSection foreignId={photo.id} createIfNotFound />
```

***

### With Dark Mode (Inline Styles)

```tsx theme={null}
function EntityPage({ entity }) {
  const [isDark, setIsDark] = useState(false);

  return (
    <>
      <p>{entity.content}</p>
      <SocialCommentSection
        entityId={entity.id}
        theme={isDark ? 'dark' : 'light'}
      />
    </>
  );
}
```

***

### With Highlighted Comment

```tsx theme={null}
import { useSearchParams } from 'react-router-dom';

function EntityPage({ entity }) {
  const [searchParams] = useSearchParams();

  return (
    <SocialCommentSection
      entityId={entity.id}
      highlightedCommentId={searchParams.get('commentId')}
    />
  );
}
```

***

### In a React Native Bottom Sheet

```tsx theme={null}
import BottomSheet from '@gorhom/bottom-sheet';

function EntityScreen({ entity }) {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <EntityView entity={entity} onCommentPress={() => setIsOpen(true)} />

      <BottomSheet isOpen={isOpen}>
        <SocialCommentSection
          entityId={entity.id}
          isVisible={isOpen}
        />
      </BottomSheet>
    </>
  );
}
```

***

## Next Steps

> [card] [File Structure](https://docs.sublay.io/v8/components/components/social/file-structure.md)
>
> Component organization

> [card] [Features](https://docs.sublay.io/v8/components/components/social/features.md)
>
> Feature overview

> [card] [Customization](https://docs.sublay.io/v8/components/customization/overview.md)
>
> Customize the component

> [card] [Installation](https://docs.sublay.io/v8/components/components/social/installation.md)
>
> Installation guide


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.