# Social Post

> One post in a feed: author, time, text with links and tags, an optional image, and reply, repost and like counts.

```tsx
'use client';

import { SocialPost } from '@brand-studio/ui';
import { pour } from '@/demos/assets';

export default function SocialPostDemo() {
  return (
    <div style={{ width: '100%', maxWidth: 560 }}>
      <SocialPost author={{ name: 'Still Coffee', handle: 'stillcoffee', verified: true }} time="2h" media={pour} replies={18} reposts={42} likes={1280} views={24600}>
        {'The Huila lot rested nine days and it is ready. A pour-over brings out the red fruit: 15 g of coffee, 250 ml of water, about three minutes.\n\nTasting on Saturday at 10:00 with @maren_roasts. #pourover'}
      </SocialPost>
    </div>
  );
}
```

## Installation

```sh
npm install @brand-studio/ui
```

React 18 or 19 is a peer dependency. Import the stylesheet once and wrap the app in a brand theme:

```tsx
import '@brand-studio/ui/styles.css';
import { BrandTheme, SocialPost } from '@brand-studio/ui';
import brand from './brand.json';

<BrandTheme palette={brand.tokens} mode="system">
  {/* your app */}
</BrandTheme>
```

## Usage

```tsx
import { SocialPost } from '@brand-studio/ui';
```

```tsx
<SocialPost
  author={{ name: 'Still Coffee', handle: 'stillcoffee', verified: true }}
  time="2h"
  dateTime="2026-10-08T07:30:00Z"
  media={pour}
  replies={18}
  reposts={42}
  likes={1280}
  onLikeChange={liked => save(postId, liked)}
>
  {'Tasting on Saturday at 10:00 with @maren_roasts. #pourover https://example.com/tasting'}
</SocialPost>
```

Pass the text as a plain string and the post finds links, @mentions and #tags and sets them in the accent colour. Line breaks in the string become line breaks in the post. Pass elements instead when you want to mark up the body yourself.

Like and repost are toggles. Each press adds you to the count or takes you off it, and calls `onLikeChange` or `onRepostChange`, so you can save it. Counts over a thousand read as `1.3K`. Leave out `views` to hide the views figure.

The avatar is the first letter of the name unless you pass `avatar`, such as an `<img>`.

## Accessibility

- Each post is an article named by its author and time.
- Reply, Repost and Like are buttons named in words with their counts; Like and Repost report `aria-pressed`.
- The verified mark is an image named **Verified**.
- Links in the text open in the same tab and are real links you can tab to.

## API Reference

| Prop | Type | Default |
|---|---|---|
| `author` | `PostAuthor` | – |
| `time` | `string` | – |
| `dateTime?` | `string` | – |
| `children` | `React.ReactNode` | – |
| `media?` | `ImageAsset` | – |
| `replies?` | `number` | – |
| `reposts?` | `number` | – |
| `likes?` | `number` | – |
| `views?` | `number` | – |
| `defaultLiked?` | `boolean` | – |
| `defaultReposted?` | `boolean` | – |
| `onReply?` | `(() => void)` | – |
| `onLikeChange?` | `((liked: boolean) => void)` | – |
| `onRepostChange?` | `((reposted: boolean) => void)` | – |
| `className?` | `string` | – |

Source: https://brandstudio.js.org/docs/components/social-post/
