Skip to main content

Overview

The ShortCutFormatter class extends the CometChatTextFormatter class to provide a mechanism for handling shortcuts within messages. This guide walks you through the process of using ShortCutFormatter to implement shortcut extensions in your CometChat application.
The Message Shortcuts extension must be enabled in your CometChat Dashboard for this feature to work.

Setup

1

Create the ShortCutFormatter Class

Define the ShortCutFormatter class by extending the CometChatTextFormatter class:
2

Override the search() Method

Override the search() method to fetch shortcuts based on the entered search text:

Usage

Initialize an instance of ShortCutFormatter and pass it to the message composer via the textFormatters prop:

Result

When users type the trigger character (!), they’ll see a list of available shortcuts to quickly insert predefined text.
ShortCut Formatter

Next Steps

Mentions Formatter

Format and style @mentions in chat messages

Message Composer

Customize the message input component

All Guides

Browse all feature and formatter guides

Message List

Customize how messages are displayed