Reaction Bar

A row of emoji reaction pills with counts. Clicking a pill selects it (highlighted), clicking again deselects unless allowDeselect is off. onReact receives the selected id or null.

Usage

<script>
  import { ReactionBar } from '@vultra/ui';

  let reactions = [
    { id: 'like', emoji: '👍', count: 42, label: 'Like' },
    { id: 'love', emoji: '❤️', count: 17, label: 'Love' },
    { id: 'laugh', emoji: '😂', count: 8, label: 'Laugh' }
  ];
  let selected = $state(null);

  function react(id) {
    selected = id;
  }
</script>

<ReactionBar {reactions} bind:selected onReact={react} />

Props

PropTypeDefaultDescription
reactionsReaction[]Pills to render
onReact(id: string \| null) => voidCalled with the selected id (or null on deselect)
selectedstring \| nullCurrently selected reaction id
allowDeselectbooleantrueAllow clicking the selected pill to deselect
classstringAdditional CSS classes

Reaction

{
  id: string;
  emoji: string;
  count: number;
  label?: string;
}

Features

  • Pill buttons with aria-pressed and accessible labels.
  • Selected pill highlighted with the primary token.
  • Counts use tabular-nums.
  • Counts of zero hide the number.