Skip to main content
Text formatters let you process message text with tracking characters, suggestion lists, and rich text transformations. Use them to add hashtag detection, custom mentions, link previews, or any text pattern processing.

CometChatTextFormatter

The CometChatTextFormatter abstract class is the base for all formatters. Its constructor takes a String trackingCharacter that triggers the formatter when typed in the composer (e.g., @ for mentions, # for hashtags).

Key Override Methods

Suggestion System

The formatter provides a built-in suggestion dropdown:

Example: Custom Hashtag Formatter

Registering Formatters

Register formatters on a component using textFormatters:
Or on the message composer:

Built-in Formatters

The UI Kit includes several built-in formatters:

Default Formatters

MessageTemplateUtils.getDefaultTextFormatters() returns the default set of formatters used by all components:

Customizing the Mentions Formatter

See the Mentions Formatter Guide for detailed styling and behavior customization.