TheDocumentation Index
Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
CometChatStickerBubble component is a presentational Angular component that renders sticker messages as images within the chat interface. It extracts the sticker image URL from the message’s metadata or custom data using a priority-based fallback chain and displays it with proper sizing, alignment, and accessibility support.
Overview
The Sticker Bubble component handles sticker message rendering while maintaining visual consistency with the design system:- Automatic URL Extraction: Extracts the sticker image URL from multiple metadata locations using a priority chain
- Alignment Variants: Supports incoming (left) and outgoing (right) message styling
- Constrained Sizing: Sticker images are capped at 150×150px with
object-fit: contain - Graceful Fallbacks: Handles missing URLs, null messages, and metadata errors without crashing
- Localized Alt Text: Uses the
conversation_subtitle_stickerlocalization key for accessibility - BEM CSS: Follows Block Element Modifier naming convention with CSS variable theming
- OnPush Change Detection: Optimal performance with minimal re-renders
Live Preview — Default sticker bubble preview.
Open in Storybook ↗
Basic Usage
Simple Sticker Bubble (Incoming)
Outgoing Sticker Message
Incoming vs Outgoing Messages
Properties
| Property | Type | Default | Description |
|---|---|---|---|
message | CometChat.CustomMessage | null | null | The sticker custom message object. The component extracts the sticker image URL from the message’s metadata or custom data |
alignment | MessageBubbleAlignment | MessageBubbleAlignment.left | Bubble alignment. left for incoming/receiver messages, right for outgoing/sender messages |
Sticker URL Extraction
The component extracts the sticker image URL from the message using a priority-based fallback chain. The first location that contains a value wins:metadata.data.sticker_url— Highest priority. Checked first viamessage.getMetadata().data.sticker_urlmetadata.sticker_url— Second priority. Checked viamessage.getMetadata().sticker_urlcustomData.sticker_url— Final fallback. Checked viamessage.getCustomData().sticker_url
message input is null/undefined, the component renders an empty container gracefully without errors.
The extraction is wrapped in a try/catch to handle cases where getMetadata() or getCustomData() might throw.
Customization
Styling with CSS Variables
The Sticker Bubble component uses CSS variables for easy customization:Available CSS Variables
| Variable | Purpose | Default |
|---|---|---|
--cometchat-spacing-2 | Container padding | 8px |
BEM CSS Classes
The component exposes the following BEM classes for targeted styling:| Class | Element | Description |
|---|---|---|
.cometchat-sticker-bubble | Block | Root container |
.cometchat-sticker-bubble--incoming | Modifier | Applied when alignment is left (incoming message) |
.cometchat-sticker-bubble--outgoing | Modifier | Applied when alignment is right (outgoing message) |
.cometchat-sticker-bubble__image | Element | The sticker <img> element (max 150×150px, object-fit: contain) |
Custom Sizing
Dark Theme
The component inherits theme changes automatically through CSS variables. No additional configuration is needed for dark theme support:Accessibility
The Sticker Bubble component follows WCAG 2.1 Level AA guidelines.ARIA Attributes
| Attribute | Element | Value | Purpose |
|---|---|---|---|
role | Container | "img" | Identifies the container as an image region |
aria-label | Container | Localized conversation_subtitle_sticker text | Provides accessible name for screen readers |
alt | Image | Localized conversation_subtitle_sticker text | Text alternative for the sticker image |
Screen Reader Behavior
Screen readers announce the sticker bubble using the localizedconversation_subtitle_sticker text (e.g., “Sticker”). When the sticker image fails to load, the alt text is retained so screen readers can still convey the content.
Best Practices
The sticker image is constrained to 150×150px with
object-fit: contain, preserving the original aspect ratio without cropping.Related Components
- CometChatMessageBubble: Parent component that delegates sticker rendering to this component
- CometChatImageBubble: Displays image messages (similar pattern, different message type)
- CometChatDeleteBubble: Displays deleted message placeholders (similar simple bubble pattern)
- CometChatMessageList: Displays lists of messages including sticker bubbles
Technical Details
- Standalone Component: Can be imported and used independently
- Change Detection: Uses OnPush change detection strategy for optimal performance
- Dependencies: Angular CommonModule, CometChat SDK, TranslatePipe for localization
- BEM CSS: Follows Block Element Modifier naming convention
- Max Dimensions: 150×150px with
object-fit: contain - URL Extraction: Priority-based fallback chain across three metadata locations