Skip to main content
The CometChatReactions component renders emoji reaction pills on a message bubble’s footer area. It dynamically calculates how many pills to show based on the parent container width and provides overflow handling via a “+N” button with a popover list.

Overview

The Reactions component provides interactive emoji reaction display:
  • Dynamic Layout: Automatically adjusts visible reaction count based on container width
  • Overflow Handling: Shows a “+N” button when reactions exceed available space, with a popover list for hidden reactions
  • Toggle Support: Clicking a reaction pill emits an event to add or remove the reaction
  • Hover Tooltips: Displays reaction info tooltips showing who reacted with each emoji
  • Alignment Aware: Adjusts popover placement based on message bubble alignment (left/right)
  • Responsive: Adapts popover placement for mobile viewports
  • Keyboard Accessible: Full keyboard support for navigating and toggling reactions
Live Preview — default reactions preview. Open in Storybook ↗

Basic Usage

Simple Reactions Display

With Custom Request Builder and Overflow Handling

Properties

PropertyTypeDefaultDescription
messageCometChat.BaseMessagerequiredThe message object containing reactions to display
alignmentMessageBubbleAlignmentMessageBubbleAlignment.leftAlignment of the message bubble (left or right). Used to determine popover placement for the overflow list
reactionsRequestBuilderCometChat.ReactionsRequestBuilderundefinedOptional custom reactions request builder for fetching reaction details
hoverDebounceTimenumber500Debounce time in milliseconds for hover tooltips

Events

EventPayload TypeDescription
reactionClick{ reaction: CometChat.ReactionCount; message: CometChat.BaseMessage }Emitted when a reaction pill is clicked. Use this to toggle (add/remove) the reaction
reactionListItemClick{ reaction: CometChat.Reaction; message: CometChat.BaseMessage }Emitted when a reaction list item is clicked from the overflow popover

Customization

CSS Variables

The Reactions component uses BEM-style CSS classes that can be customized:

Theming

The component adapts to light and dark themes through CSS variables:

Accessibility

Keyboard Navigation

KeyAction
TabMove focus between reaction pills and the more button
Enter / SpaceToggle the focused reaction (add or remove)
Enter / Space on “+N”Open the overflow reaction list popover

ARIA Attributes

ElementAttributeValueDescription
Reaction pillrole"button"Indicates the pill is interactive
Reaction pillaria-labelDynamicDescribes emoji, count, and whether the current user reacted
Reaction pilltabindex"0"Makes the pill focusable
More buttonrole"button"Indicates the overflow button is interactive
More buttonaria-labelDynamicDescribes the number of hidden reactions

Screen Reader Support

  • Reaction pills announce the emoji, count, and user reaction status
  • Toggling a reaction announces whether it was added or removed via a live region
  • The overflow button announces how many additional reactions are hidden