Skip to content
Calm motion: animations on this site only fade, with no movement

Reactions ​

Emoji reactions with counts under a post

Lets readers react to a post or a message with an emoji. Each reaction shows its count. A click adds or removes the reaction of the reader, and a button opens the emoji picker for a new one.

Basic

Episode 41 is out: we recorded it in a wardrobe, and it sounds better than the studio.

  • v-model is a list of reactions. Each reaction has an emoji and a count. If the reader is one of the people who reacted, set active to true. It is the BlessReaction type of the chat bubble.
  • A click on a reaction adds the reader to it or removes the reader from it, and changes count and active. A reaction with a count of zero goes away. Each click emits toggle with the emoji and the new state. Send it to your server.
  • The last button opens the emoji picker. A picked emoji adds a new reaction, or joins the reaction that has it. :addable="false" hides this button.
  • max sets how many reactions one reader can add (default 0, no limit). At the limit, the other buttons are disabled.
  • The reaction of the reader has the accent border and a bold count. Each button is a toggle with aria-pressed, and its name says the emoji and the count. Change the words with labels or a label pack: add, group, and reaction (a function of the emoji and the count).

Usage ​

ts
import { BlessReactions } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
addablebooleantrueshow the button that opens the emoji picker; false hides it
maxnumber0reactions a reader can add at most, counting their own; 0 has no limit
labelsPartial<{ add: string; group: string; reaction: (emoji: string, count: number) => string; }>—
modelValueBlessReaction[][]the reactions, with the same type as in `BlessBubble`; a click changes `count` and `active`

Events

NamePayloadDescription
update:modelValue[value: BlessReaction[]]
toggle[emoji: string, on: boolean]

Released under the MIT License. Character names and artwork belong to their owners.