affectUI › Components › Buttons

Reaction Bar

Like, comment, repost and share in one pill – icons pop and fill, counts roll in digit by digit.

Free and open source (MIT). Install: npx shadcn@latest add https://www.affectui.com/r/reaction-bar.json · Import from @/components/ui/reaction-bar

When to use

  • Reactions under posts, comments or updates in a feed
  • Any toggle with a public count, like saves or upvotes

When not to use

  • Actions that need a confirmation – a toggle gives none

Usage

import { ReactionBar } from "@/components/ui/reaction-bar";

export function PostActions({ post }) {
  return (
    <ReactionBar
      reactions={{ like: { count: post.likes, active: post.liked }, comment: { count: post.comments } }}
      onReact={(key, state) => api.react(post.id, key, state.active)}
    />
  );
}

Props

NameTypeDefaultDescription
reactionsPartial<Record<ReactionKey, { count; active? }>>Starting count and pressed state per action
onReact(key, state) => voidCalled after a toggle with the new count and state
actionsReactionKey[]["like", "comment", "repost", "share"]Which actions to show, in order
classNamestringExtra class on the pill

Keyboard

  • Tab: Move between the actions
  • Enter / Space: Toggle the focused action

Accessibility

  • Every action is a toggle button with aria-pressed and a label that includes its count
  • The rolling digits are decorative – the label carries the number

Responsive

  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Button – Primary, secondary, ghost and destructive buttons with icons, sizes and a shimmering loading state
  • Comments Panel – Comment feed with filters, runnable /edit commands, resolve and a composer