Reaction bar
Emoji with their count, yours pressed, who reacted in a tooltip, and a button to add one.
import { ReactionBar, toggleConversationReaction, conversationReactionLabel } from "@forgeron/ui";import { ReactionBar, toggleConversationReaction, type ConversationReaction } from "@forgeron/ui";
import { useState } from "react";
const me = { id: "me", name: "You" };
export default function Default() {
const [reactions, setReactions] = useState<ConversationReaction[]>([
{
emoji: "๐",
users: [{ id: "lea", name: "Lรฉa Martin" }, { id: "karim", name: "Karim Aziz" }, me],
},
{ emoji: "๐", users: [{ id: "sam", name: "Sam Roche" }] },
]);
return (
<ReactionBar
reactions={reactions}
currentUserId="me"
onToggle={(emoji) => setReactions((r) => toggleConversationReaction(r, emoji, me))}
/>
);
}API โ Props
| Prop | Type | Default | Description |
|---|---|---|---|
reactions | { emoji, users: { id, name }[] }[] | โ | In order of first use. |
currentUserId | string | โ | Whose reaction is pressed. |
onToggle | (emoji) => void | โ | A chip pressed or an emoji chosen in the picker. |
canAdd / readOnly / categories | boolean; boolean; EmojiCategory[] | โ | The add button, and your own set. |
className | string | โ | Extra classes. |