Skip to main content
The CometChatMessageBubble component is a versatile container component that renders chat messages with configurable view slots. It serves as the primary wrapper for displaying messages in the CometChat Angular UIKit, handling message alignment, options menus, status indicators, and content rendering based on message type.

Overview

The Message Bubble component provides a flexible architecture for rendering different message types while maintaining consistent styling and behavior:
  • Message Type Routing: Automatically renders appropriate bubble component based on message type (text, image, video, audio, file)
  • Configurable View Slots: Override any section (leading, header, content, footer, etc.) with custom templates
  • Message Options Menu: Context menu with hover/click behavior for message actions
  • Group vs 1-on-1 Handling: Automatically shows/hides avatar and sender name based on conversation type
  • Alignment Variants: Supports incoming (left), outgoing (right), and action (center) alignments
  • Status Indicators: Displays timestamps, read receipts, and edited labels
  • Reply Preview: Shows quoted message preview for replies
  • Accessibility: Full keyboard navigation and screen reader support
Live Preview — Default message bubble preview. Open in Storybook ↗

Message Bubble Structure

The Message Bubble is composed of several configurable view slots that can be customized independently:

View Slot Descriptions

Basic Usage

Simple Message Bubble

Incoming vs Outgoing Messages

With Message Options

API Reference

Properties

View Override Properties

Display Control Properties

Events

Bubble Parts Customization

Each bubble part can be customized independently using Angular TemplateRef. The customization follows a priority system:
  1. Input template ref (passed directly to component) - Highest priority
  2. Service configured view (via MessageBubbleConfigService) - Medium priority
  3. Default rendering - Lowest priority

bubbleView

The bubbleView provides complete control over the entire message bubble. When set, it replaces all other views (header, content, footer, etc.). Use Case: When you need a completely custom message layout that doesn’t follow the standard structure.

leadingView

The leadingView customizes the avatar section that appears on the left side of incoming messages in group conversations. Use Case: Custom avatar styling, adding status badges, or showing additional user information.

headerView

The headerView customizes the sender name section that appears above the message content in group conversations. Use Case: Adding user roles, custom badges, or additional sender information.

replyView

The replyView customizes the quoted message preview that appears when a message is a reply to another message. Use Case: Custom reply preview styling, showing additional context, or different preview formats.

contentView

The contentView customizes the main message content area. This is where the actual message (text, image, video, etc.) is displayed. Use Case: Custom message rendering, adding interactive elements, or completely different content layouts.

statusInfoView

The statusInfoView customizes the timestamp and delivery status section that appears inside the message bubble. Use Case: Custom timestamp formats, additional status indicators, or different receipt icons.

bottomView

The bottomView customizes the section below the main content, typically used for link previews, warnings, or additional information. Use Case: Link previews, content warnings, or expandable content sections.

footerView

The footerView customizes the reactions section that appears below the message content. Use Case: Custom reaction display, adding additional footer actions, or different reaction layouts.

threadView

The threadView customizes the thread reply indicator that appears when a message has replies. Use Case: Custom thread indicators, showing reply previews, or different thread navigation styles.

Service-Based Customization

For global customization across all message bubbles, use the MessageBubbleConfigService. This allows you to set custom views that apply to all instances without passing templates to each component.

Using MessageBubbleConfigService

MessageBubbleConfigService API

Scoping for Multiple Instances

By default, MessageBubbleConfigService is a root-level singleton — all message bubbles share the same configuration. If you need different bubble customizations for different message lists (e.g., a main chat vs. a thread panel), create a wrapper component that provides its own instance:
See CometChatMessageList — Multiple Message Lists with Different Configurations for a complete example.

BubblePart Type

CSS Customization

Styling with CSS Variables

The Message Bubble component uses CSS variables for consistent theming. Override these variables to customize the appearance:

Component-Specific CSS Variables

In addition to the global theme tokens above, the Message Bubble component exposes its own overridable CSS custom properties, prefixed with --cometchat-message-bubble-. Override these to customize appearance for this component specifically, independently of the global theme tokens.
The component exposes --cometchat-message-bubble- prefixed CSS custom properties that can be overridden. Inspect the rendered .cometchat-message-bubble element in your browser’s developer tools to discover the exact variable names exposed by your installed version of the UI Kit.

Dark Theme

Component-Specific Styling

Target specific bubble elements using BEM class names:

Advanced Usage

Group Conversation with Avatar and Sender Name

With Text Formatters

With Message Translation

Accessibility

The Message Bubble component is fully accessible and follows WCAG 2.1 Level AA guidelines:

Keyboard Support

ARIA Attributes

Screen Reader Announcements

The component provides meaningful announcements for:
  • Message sender and type
  • Message status (sent, delivered, read)
  • Edited messages
  • Reactions and their counts
  • Thread reply counts

Best Practices

Use the group property to enable avatar and sender name display in group conversations.
Always provide the complete CometChat message object to ensure proper rendering of all message types.
The component automatically determines the appropriate bubble component based on message type. Use contentView only when you need custom rendering.
Handle optionClick events to implement message actions like reply, copy, delete, etc.
When using custom templates, ensure you maintain accessibility by including proper ARIA attributes and keyboard navigation.
Use CSS variables for styling to ensure your customizations work correctly with both light and dark themes.