CometChatTextFormatter class with the same API pattern:
- Kotlin XML:
com.cometchat.uikit.kotlin.shared.formatters.CometChatTextFormatter - Jetpack Compose:
com.cometchat.uikit.compose.presentation.shared.formatters.CometChatTextFormatter
CometChatTextFormatter API
The abstract class takes atrackingCharacter that triggers the formatter when typed in the composer (e.g., @ for mentions, # for hashtags).
Key Override Methods
Suggestion System
Example: Custom Hashtag Formatter
- Kotlin (XML Views)
- Jetpack Compose
Registering Formatters
- Kotlin (XML Views)
- Jetpack Compose
Built-in Formatter: CometChatMentionsFormatter
The UI Kit includesCometChatMentionsFormatter as a built-in formatter that handles @mention detection, user suggestion lists, and spannable highlighting. It’s automatically added to components when mentions are enabled.
Each module has its own implementation:
- Kotlin XML:
com.cometchat.uikit.kotlin.shared.formatters.CometChatMentionsFormatter - Jetpack Compose:
com.cometchat.uikit.compose.presentation.shared.formatters.CometChatMentionsFormatter
Related
- Mentions Formatter Guide — Built-in mentions formatter reference.
- Customization Overview — See all customization categories.