Skip to main content
Version: v4

Reactions

Overview

The CometChatReactions component provides a visual representation of emoji reactions associated with a specific message. It enables users to quickly identify which emojis were used to react to the message and by whom.

Image

Usage

Integration

The following code snippet illustrates how you can directly incorporate the Reactions component into your app.

import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';

@NgModule({
imports: [
BrowserModule,
],
declarations: [AppComponent],
providers: [],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { }

Actions

Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

1. reactionClick

reactionClick is triggered when you click on each Reaction in the footer view of message bubble. You can override this action using the following code snippet.

Example

In this example, we are employing the reactionClick action.

import { CometChat } from '@cometchat/chat-sdk-javascript';
import { Component, OnInit } from '@angular/core';
import { CometChatThemeService, CometChatUIKit } from '@cometchat/chat-uikit-angular';
import "@cometchat/uikit-elements";

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {

constructor(private themeService:CometChatThemeService) {
themeService.theme.palette.setMode("light")
themeService.theme.palette.setPrimary({ light: "#6851D6", dark: "#6851D6" })
}
public messageObject!: CometChat.TextMessage;
ngOnInit(): void {
CometChat.getMessageDetails("c").then((message) => {
this.messageObject = message;
}).catch((error) => {
console.error('Error fetching message details:', error);
});
}
public handleOnReactionClick = (reaction: CometChat.ReactionCount, message: CometChat.BaseMessage): void =>{
console.log("your custom on reaction click actions");
};
onLogin(UID?: any) {
CometChatUIKit.login({ uid: UID }).then(
(user) => {
setTimeout(() => {
window.location.reload();
}, 1000);
},
(error) => {
console.log("Login failed with exception:", { error });
}
);
}
}

Filters

Filters allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of ChatSDK.

The Reactions component does not have any exposed filters.

Events

Events are emitted by a Component. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.

The Reactions component does not produce any events.

Customization

To fit your app's design requirements, you can customize the appearance of the Reaction component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.

1. reactionsStyle

To customize the appearance, you can assign a reactionsStyle object to the Reactions component.

Example

In this example, we are employing the reactionsStyle.

import { CometChat } from '@cometchat/chat-sdk-javascript';
import { Component, OnInit } from '@angular/core';
import { CometChatThemeService, CometChatUIKit } from '@cometchat/chat-uikit-angular';
import { ReactionsStyle } from '@cometchat/uikit-shared';
import "@cometchat/uikit-elements";

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {

constructor(private themeService:CometChatThemeService) {
themeService.theme.palette.setMode("light")
themeService.theme.palette.setPrimary({ light: "#6851D6", dark: "#6851D6" })
}
public messageObject!: CometChat.TextMessage;
ngOnInit(): void {
CometChat.getMessageDetails("messageId").then((message) => {
this.messageObject = message;
}).catch((error) => {
console.error('Error fetching message details:', error);
});
}
reactionsStyle = new ReactionsStyle({
background:'#b067f5',
border:'2px solid #881ced',
borderRadius:'20px',
width:'170px',
});
onLogin(UID?: any) {
CometChatUIKit.login({ uid: UID }).then(
(user) => {
setTimeout(() => {
window.location.reload();
}, 1000);
},
(error) => {
console.log("Login failed with exception:", { error });
}
);
}
}
Image

List of properties exposed by ReactionsStyle

PropertyDescriptionCode
borderUsed to set borderborder?: string,
borderRadiusUsed to set border radiusborderRadius?: string;
backgroundUsed to set background colourbackground?: string;
heightUsed to set heightheight?: string;
widthUsed to set widthwidth?: string;
barPaddingused to set the bar paddingbarPadding?: string;
reactionBoxShadowused to set the reactions box-shadowreactionBoxShadow?: string;
reactionBorderRadiusused to set the reactions border radiusreactionBorderRadius?: string;
reactionBorderused to set the reactions borderreactionBorder?: string;
reactionBackgroundused to set the reactions backgroundreactionBackground?: string;
activeReactionBorderused to set the active reactions borderactiveReactionBorder?: string;
activeReactionBackgroundused to set the active reactions backgroundactiveReactionBackground?: string;
reactionEmojiFontused to set the reaction emoji text fontreactionEmojiFont?: string;
reactionCountTextFontused to set the reaction count text fontreactionCountTextFont?: string;
reactionCountTextColorused to set the reaction count text colorreactionCountTextColor?: string;
activeReactionCountTextFontused to set the active reaction text fontactiveReactionCountTextFont?: string;
activeReactionCountTextColorused to set the active reaction text coloractiveReactionCountTextColor?: string;
baseReactionBackgroundused to set the base reaction backgroundbaseReactionBackground?: string;

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.

import { CometChat } from '@cometchat/chat-sdk-javascript';
import { Component, OnInit } from '@angular/core';
import { CometChatThemeService, CometChatUIKit } from '@cometchat/chat-uikit-angular';
import { MessageBubbleAlignment } from '@cometchat/uikit-resources';
import "@cometchat/uikit-elements";

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {

constructor(private themeService:CometChatThemeService) {
themeService.theme.palette.setMode("light")
themeService.theme.palette.setPrimary({ light: "#6851D6", dark: "#6851D6" })
}
public messageObject!: CometChat.TextMessage;
ngOnInit(): void {
CometChat.getMessageDetails("messageId").then((message) => {
this.messageObject = message;
}).catch((error) => {
console.error('Error fetching message details:', error);
});
}
alignment = MessageBubbleAlignment.right;
onLogin(UID?: any) {
CometChatUIKit.login({ uid: UID }).then(
(user) => {
setTimeout(() => {
window.location.reload();
}, 1000);
},
(error) => {
console.log("Login failed with exception:", { error });
}
);
}
}

Below is a customizations list along with corresponding code snippets

PropertyDescriptionCode
alignment report Used to set the allignment of the reactions. it can be either left, right or center[alignment]="alignment"
hoverDebounceTime report Used to sets the delay before displaying the tooltip reaction information when hovering over reactions[hoverDebounceTime]="100"

Configuration

Configurations offer the ability to customize the properties of each component within a Composite Component.

Reaction Info

If you want to customize the properties of the Reaction Info Component inside Reactions Component, you need use the reactionInfoConfiguration object.

Image
import { CometChat } from '@cometchat/chat-sdk-javascript';
import { Component, OnInit } from '@angular/core';
import { CometChatThemeService, CometChatUIKit } from '@cometchat/chat-uikit-angular';
import { ReactionInfoConfiguration, ReactionInfoStyle } from '@cometchat/uikit-shared';
import "@cometchat/uikit-elements";

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {

constructor(private themeService:CometChatThemeService) {
themeService.theme.palette.setMode("light")
themeService.theme.palette.setPrimary({ light: "#6851D6", dark: "#6851D6" })
}
public messageObject!: CometChat.TextMessage;
ngOnInit(): void {
CometChat.getMessageDetails("messageId").then((message) => {
this.messageObject = message;
}).catch((error) => {
console.error('Error fetching message details:', error);
});
}
reactionInfoConfiguration = new ReactionInfoConfiguration({
reactionInfoStyle: new ReactionInfoStyle({
background:'#631aeb',
borderRadius:'20px'
}),
//properties of reaction info
});
onLogin(UID?: any) {
CometChatUIKit.login({ uid: UID }).then(
(user) => {
setTimeout(() => {
window.location.reload();
}, 1000);
},
(error) => {
console.log("Login failed with exception:", { error });
}
);
}
}

The reactionInfoConfiguration indeed provides access to all the Action, Filters, Styles, Functionality, and Advanced properties of the Reaction Info component.

In the above example, we are styling a few properties of the Reaction Info component using reactionInfoConfiguration.

Reaction List

If you want to customize the properties of the Reaction List Component inside Reactions Component, you need use the reactionListConfiguration object.

Image
import { CometChat } from '@cometchat/chat-sdk-javascript';
import { Component, OnInit } from '@angular/core';
import { CometChatThemeService, CometChatUIKit } from '@cometchat/chat-uikit-angular';
import { ReactionListConfiguration, ReactionListStyle } from '@cometchat/uikit-shared';
import "@cometchat/uikit-elements";

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {

constructor(private themeService:CometChatThemeService) {
themeService.theme.palette.setMode("light")
themeService.theme.palette.setPrimary({ light: "#6851D6", dark: "#6851D6" })
}
public messageObject!: CometChat.TextMessage;
ngOnInit(): void {
CometChat.getMessageDetails("messageId").then((message) => {
this.messageObject = message;
}).catch((error) => {
console.error('Error fetching message details:', error);
});
}
reactionListConfiguration = new ReactionListConfiguration({
reactionListStyle: new ReactionListStyle({
background:'#631aeb',
border:'2px solid #881ced'
}),
//properties of reaction list
});
onLogin(UID?: any) {
CometChatUIKit.login({ uid: UID }).then(
(user) => {
setTimeout(() => {
window.location.reload();
}, 1000);
},
(error) => {
console.log("Login failed with exception:", { error });
}
);
}
}

The reactionListConfiguration indeed provides access to all the Action, Filters, Styles, Functionality, and Advanced properties of the Reaction List component.

In the above example, we are styling a few properties of the Reaction List component using reactionListConfiguration.