Skip to main content

What It Is

CometChatMessageTemplate is a model class, not a rendered component. Each instance maps a message type + category pair to a set of view functions that control how that message renders inside CometChatMessageList. Pass an array of templates to the templates prop on CometChatMessageList.

Template Structure

A message bubble is composed of these view slots, each overridable per template:

Fetching Existing Templates

Retrieve the built-in templates and modify specific ones:

Common Patterns

Custom header with status badge

Custom content view for a custom message type

Custom bottom view with warning

Replace entire bubble

Custom action sheet options

New template for a custom message type


Styling

CometChatMessageTemplate renders inside .cometchat-message-bubble. Style individual bubble sections using CSS:

Properties

bubbleView

Replaces the entire message bubble. When set, headerView, contentView, footerView, bottomView, statusInfoView, and replyView are ignored for that template.

bottomView

Custom bottom section below the content area. Default renders link previews or “load more” for long messages.

category

Maps the template to a CometChat message category (e.g., CometChatUIKitConstants.MessageCategory.message, CometChatUIKitConstants.MessageCategory.custom).

contentView

Custom content area. Default renders text, image, video, audio, or file bubble based on message type.

footerView

Custom footer below the content area. Default renders reactions.

headerView

Custom header above the content area. Default renders sender name.

options

Returns the list of action sheet items for long-press on a message bubble.

replyView

Custom reply preview above the content area.

statusInfoView

Custom status info area. Default renders receipt icon and timestamp.

type

Maps the template to a CometChat message type (e.g., CometChatUIKitConstants.MessageTypes.text, CometChatUIKitConstants.MessageTypes.image).