AI Integration Quick Reference
AI Integration Quick Reference
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.
The Formatter Interface
TheCometChatTextFormatter class provides the foundation for all text formatters in React Native:
Steps
1. Import the base class
2. Extend it
3. Match the pattern in formatRawText
formatRawText() receives the raw message text as a string, before any of the UI Kit’s own parsing, and returns a string. Rewrite your pattern into markup the UI Kit already draws — here, color and bold:
Example
A hashtag formatter used withCometChatMessageList and CometChatCompactMessageComposer.
hello #world **bold** _italic_ now renders #world green and bold, with the Markdown around it still formatted.
A formatter only applies where you register it.
CometChatMessageList, CometChatConversations, CometChatSearch, CometChatPinnedMessages, CometChatSavedMessages and CometChatCompactMessageComposer each take textFormatters. Media captions, the quoted reply inside a bubble, the reply and edit previews, and the message information screen inherit it from the component that renders them.Methods Reference
Advanced: Suggestion List Integration
For formatters that need to show suggestions (like mentions), implement thesearch method:
Next Steps
Custom Text Formatter
Build an app-defined color marker end to end.
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.