Skip to main content
CometChatTextFormatter is an abstract class for formatting text in the message composer and message bubbles. Extend it to build custom formatters — hashtags, keywords, or any regex-based pattern.

Base Class Overview

The CometChatTextFormatter class provides the foundation for all text formatters in React Native:

Steps

1. Import the base class

2. Extend it

3. Implement formatting methods

Override getFormattedText to apply custom styling to matched patterns:

Example

A hashtag formatter used with CometChatMessageList and CometChatMessageComposer.

Methods Reference


Advanced: Suggestion List Integration

For formatters that need to show suggestions (like mentions), implement the search method:

Next Steps

Mentions Formatter

Add @mentions with styled tokens.

URL Formatter

Auto-detect and style URLs as clickable links.

All Guides

Browse all feature and formatter guides.

Sample App

Full working sample application on GitHub.