Skip to main content
CometChatMentionsFormatter extends CometChatTextFormatter to format @mentions in text messages. It styles mention tokens, generates suggestion lists as users type, and handles click events on rendered mentions.

Usage

1. Initialize the formatter

2. Format a message

Provide the raw message string containing mention placeholders, then apply the formatter:
The output contains HTML with styled mentions ready for rendering.

3. Pass to components

Use the textFormatters input on cometchat-message-list, cometchat-message-composer, or cometchat-conversations.
The CometChatMentionsFormatter is included by default in the message composer and message list. You only need to pass it explicitly if you want to customize its behavior or combine it with other formatters.

Customization

Custom mention styles

Override the default mention token styles by setting CSS properties:

Custom click handler

Handle clicks on mention tokens to navigate to user profiles or show details:

Next Steps

Custom Text Formatter

Build custom inline text patterns.

Message List

Render real-time message threads.

All Guides

Browse all feature and formatter guides.

URL Formatter

Auto-detect and style URLs as clickable links.