---
title: "Social Action"
description: "A pill toggle for like, save, repost, or follow. On a press a jelly disc blooms into a ring, confetti flies out, and the count rolls up."
url: https://gelatinui.com/components/social-action
markdown_url: https://gelatinui.com/components/social-action.md
access: free
install: "npx shadcn@latest add @gelatin-ui/social-action"
registry_item: https://gelatinui.com/r/social-action.json
version: "2026-11-21"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Social Action

> A pill toggle for like, save, repost, or follow. On a press a jelly disc blooms into a ring, confetti flies out, and the count rolls up.

Page: https://gelatinui.com/components/social-action

## When to use it

Best for: One social action on a post or a profile: a pill toggle with an animated icon, a burst, and a rolling count.

- Put a `SocialActionIcon` with an animated icon and a `SocialActionCount` or a `SocialActionLabel` inside `SocialAction`.
- Pick the action color with `color`: `rose` for like, `amber` for save, `green` for repost, `blue` for follow.
- Use `variant="ghost"` in an action row under a post, and `soft` or `outline` when the action stands alone.
- Set `effect` on the icon part: `bloom` for a big moment, `firework` for a playful one, `none` for a calm one such as Follow.

## When not to use it

- For an on and off control with no count or burst, such as Bold or Mute, use a [Toggle](https://gelatinui.com/components/toggle.md).

## Notes for agents

- `pressed` and `onPressedChange` (controlled) or `defaultPressed`. `eventDetails.cancel()` keeps the old state.
- `SocialActionCount` takes `count`: the count without this person's action. It shows `count + 1` while pressed. `NaN` and negative counts show 0.
- Counts from 10,000 read compact (`12.4K`). Pass `format` to change it.
- `SocialActionIcon` takes `render`: the icon element gets `checked` and `aria-hidden`. Pass `<AnimatedHeartIcon burst={false} />` so two bursts do not stack.
- An icon-only action needs an `aria-label`. Keep the name the same in both states.
- `size` is `sm` (28 px), `default` (32), `lg` (36), or `xl` (40).

## Anatomy

```text
SocialAction
├─ SocialActionIcon (0..n)
├─ SocialActionCount (0..n)
└─ SocialActionLabel (0..n)
```

## API reference

### SocialAction

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `color` | `"amber" \| "blue" \| "green" \| "rose"` | "rose" |  |
| `size` | `"default" \| "lg" \| "sm" \| "xl"` | "default" |  |
| `variant` | `"ghost" \| "outline" \| "soft"` | "soft" |  |
| `className` | `string` |  |  |

Also takes every prop of Base UI `Toggle`: https://base-ui.com/react/components/toggle

### SocialActionIcon

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `render` | `RenderProp` |  | The icon. An element gets `checked` (the pressed state) and `aria-hidden`, so an animated icon plays on its own: `<AnimatedHeartIcon burst={false} />`. A function gets the props and `{ pressed }` for any other icon. |
| `effect` | `"bloom" \| "firework" \| "none"` | "bloom" | What plays on a press to on: `bloom` (default: a jelly disc that hollows into a ring, and 7 spokes of confetti), `firework` (a fountain of 12 drops that falls with gravity), or `none` (only the icon pop). A press to off fades a playing effect out. |

### SocialActionCount

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `locale` | `string` |  | The BCP 47 locale of the digits and marks ("de-DE"). Default: the `DisplayLocaleProvider` locale, else `"en-US"` (`useDisplayLocale`). Never the browser language, so a server render and the first browser render write the same number. |
| `format` | `NumberFormatOptions` |  | The options of `Intl.NumberFormat`: `style` (`currency`, `percent`, `unit`), `notation` (`compact`), the fraction digits, `signDisplay`, `numberingSystem`, and the others. Its parts (`formatToParts`) decide the columns: each digit rolls, each other part fades. |
| `trend` | `"auto" \| "down" \| "shortest" \| "up"` |  | The direction of each roll. `auto` (the default) takes it from the value: a bigger value rolls up (the new digit comes in from below), a smaller one rolls down. `shortest` turns each column the short way round on its own (a clock or a slot machine look). |
| `snap` | `"always" \| "fast" \| "never"` |  | When a change shows the new digits at once, with no roll and no fade. `never` (the default) rolls each change. `fast` jumps while the value changes fast (a new value less than one roll after the last, as a pointer that scrubs a chart sends), and rolls again on the first change after a pause. `always` never rolls. |
| `count` | `number` |  | The count without this person's action: the part shows `count + 1` while pressed, so a press rolls it up by one and a second press rolls it back. A count that is not a finite number of 0 or more (a `NaN` from a failed load, a negative from a race) shows as 0. |

### SocialActionLabel

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `function \| ReactNode` |  | The word, or a function of the pressed state for a word that changes: Follow, Following. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| SocialAction | `social-action` | `data-disabled` | `--social-action-glow`, `--social-action-mint`, `--social-action-sky`, `--social-action-tone` | `hit-area` |
| SocialActionIcon | `social-action-icon` | `data-pressed` | `--animated-heart-icon-color`, `--social-action-tone` |  |
| SocialActionCount | `social-action-count` |  |  |  |
| SocialActionLabel | `social-action-label` |  |  |  |

## Usage

Compose the action from its icon and its count, and give it a name.

The sample also uses `animated-bookmark-icon`, `animated-heart-icon`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui/social-action @gelatin-ui-pro/animated-bookmark-icon @gelatin-ui-pro/animated-heart-icon
```

```tsx title="post-actions.tsx"
import { SocialAction, SocialActionCount, SocialActionIcon } from "@/components/actions/social-action";
import { AnimatedBookmarkIcon } from "@/components/pro/icons/animated-bookmark-icon";
import { AnimatedHeartIcon } from "@/components/pro/icons/animated-heart-icon";

export function PostActions({ likes, saves }: { likes: number; saves: number }) {
  return (
    <div className="hit-area-row flex items-center gap-1">
      <SocialAction color="rose" variant="ghost" aria-label="Like">
        <SocialActionIcon effect="bloom" render={<AnimatedHeartIcon burst={false} />} />
        <SocialActionCount count={likes} />
      </SocialAction>
      <SocialAction color="amber" variant="ghost" aria-label="Save">
        <SocialActionIcon effect="firework" render={<AnimatedBookmarkIcon />} />
        <SocialActionCount count={saves} />
      </SocialAction>
    </div>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/social-action
```

It adds 29 registry items: 26 files, 4868 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Rolling Number](https://gelatinui.com/components/rolling-number.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Toggle](https://gelatinui.com/components/toggle.md)
- [Animated Heart Icon](https://gelatinui.com/components/animated-heart-icon.md)
- [Animated Bookmark Icon](https://gelatinui.com/components/animated-bookmark-icon.md)
- [Rolling Number](https://gelatinui.com/components/rolling-number.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Enter | Turns the action on or off. |
| Space | Turns the action on or off. |

## Accessibility

It is a toggle button: assistive tools read its name and the pressed state.

The icon and the effect are hidden from assistive tools. The count is read as text.

## Motion

| Part | Motion |
| --- | --- |
| Bloom | panel · the icon hides, a jelly disc grows and hollows into a ring, the icon pops through, then confetti |
| Firework | panel · 12 drops rise in a fountain and fall with gravity |
| Count | panel · each digit rolls up on a press to on and down on a press to off |
| Press | press · the pill sinks to 97% while it is held |
| Undo | fade · a press to off fades a playing effect out |
