> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-rn-guide-message-privately.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Message Template

> Data structure defining how message bubbles render in CometChatMessageList — controls header, content, footer, bottom, status info, reply, and bubble views per message type and category.

<Accordion title="AI Agent Component Spec">
  ```json theme={null}
  {
    "component": "CometChatMessageTemplate",
    "kind": "model-class",
    "package": "cometchat_chat_uikit",
    "import": "import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';",
    "description": "Data structure defining how message bubbles render in CometChatMessageList. Each template maps a type+category pair to view functions.",
    "usage": "Pass a list of CometChatMessageTemplate instances to CometChatMessageList via the templates property.",
    "properties": {
      "type": { "type": "String", "required": true, "description": "CometChat message type" },
      "category": { "type": "String", "default": "\"\"", "description": "CometChat message category" },
      "headerView": { "type": "Function?", "default": "null", "description": "Custom header view builder function" },
      "contentView": { "type": "Function?", "default": "null", "description": "Custom content view builder function" },
      "footerView": { "type": "Function?", "default": "null", "description": "Custom footer view builder function" },
      "bottomView": { "type": "Function?", "default": "null", "description": "Custom bottom view builder function" },
      "bubbleView": { "type": "Function?", "default": "null", "description": "Replaces entire bubble" },
      "statusInfoView": { "type": "Function?", "default": "null", "description": "Custom status info view builder function" },
      "replyView": { "type": "Function?", "default": "null", "description": "Custom reply preview builder function" },
      "threadView": { "type": "Function?", "default": "null", "description": "Custom thread view builder function" },
      "options": { "type": "Function", "description": "Returns action sheet items for long-press" }
    },
    "relatedComponents": ["CometChatMessageList"],
    "events": null
  }
  ```
</Accordion>

## Overview

A MessageTemplate provides you with the capability to define and customize both the structure and the behavior of the [MessageBubble](/ui-kit/flutter/v5/message-bubble-styling). It acts as a schema or design blueprint for the creation of a variety of [MessageBubble](/ui-kit/flutter/v5/message-bubble-styling) widgets, allowing you to manage the appearance and interactions of [MessageBubble](/ui-kit/flutter/v5/message-bubble-styling) within your application effectively and consistently.

### Structure

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/FGBCGWXGo5d9bVxR/images/c2932cff-message_template_structure-68b310b513e3dc3c089c65b88d99196c.png?fit=max&auto=format&n=FGBCGWXGo5d9bVxR&q=85&s=c5c1eb4f32c99eb71c519930cb54d6e4" width="2560" height="1600" data-path="images/c2932cff-message_template_structure-68b310b513e3dc3c089c65b88d99196c.png" />
</Frame>

The MessageBubble structure can typically be broken down into the following widgets:

1. **Leading widget**: This is where the sender's avatar is displayed. It's typically on the left of the MessageBubble for messages from others and on the right for messages from the current user.

2. **Header widget**: This displays the sender's name and is especially useful in group chats where multiple users are sending messages.

3. **Content widget**: This is the core of the MessageBubble where the message content (text, images, videos, etc.) is displayed.

4. **Bottom widget**: This widget can be used to extend the MessageBubble with additional elements, such as link previews or a 'load more' button for long messages. It's typically placed beneath the Content widget.

5. **Footer widget**: This is where the timestamp of the message and its delivery or read status are displayed. It's located at the bottom of the MessageBubble.

### Properties

MessageTemplate provides you with methods that allow you to alter various properties of the MessageBubble. These properties include aspects such as the `type` and `category` of a message, the appearance and behavior of the header, content, and footer sections of the message bubble,

1. **Type**

   Using `type` you can set the type of CometChatMessage, This will map your MessageTemplate to the corresponding CometChatMessage. You can set the MessageTemplate Type using the following code snippet.

   <Tabs>
     <Tab title="Dart">
       ```dart theme={null}
       CometChatMessageTemplate cometChatMessageTemplate = CometChatMessageTemplate(type: MessageTypeConstants.text);
       ```
     </Tab>
   </Tabs>

2. **Category**

   Using `category` you can set the category of a MessageTemplate. This will create a MessageTemplate with the specified category and link it with a CometChatMessage of the same category.

   Please refer to our guide on [Message Categories](/sdk/flutter/message-structure-and-hierarchy) for a deeper understanding of message categories.

   <Tabs>
     <Tab title="Dart">
       ```dart theme={null}
       CometChatMessageTemplate cometChatMessageTemplate = CometChatMessageTemplate(category: MessageCategoryConstants.custom);
       ```
     </Tab>
   </Tabs>

3. **Header Widget**

   The. `headerView` property allows you to assign a custom header widget to the MessageBubble. By default, it is configured to display the sender's name.

   <Tabs>
     <Tab title="Dart">
       ```dart theme={null}
       cometChatMessageTemplate.headerView = (BaseMessage baseMessage, BuildContext buildContext, BubbleAlignment alignment) {
           return const Placeholder();
       };
       ```
     </Tab>
   </Tabs>

4. **Content Widget**

   The `contentView` method allows you to assign a custom content widget to the MessageBubble. By default, it displays the [Text Bubble](/ui-kit/flutter/v5/message-bubble-styling#text-bubble), [Image Bubble](/ui-kit/flutter/v5/message-bubble-styling#image-bubble), [File Bubble](/ui-kit/flutter/v5/message-bubble-styling#file-bubble), [Audio Bubble](/ui-kit/flutter/v5/message-bubble-styling#audio-bubble), or [Video Bubble](/ui-kit/flutter/v5/message-bubble-styling#video-bubble), depending on the message type.

   <Tabs>
     <Tab title="Dart">
       ```dart theme={null}
       cometChatMessageTemplate.contentView = (BaseMessage baseMessage, BuildContext buildContext, BubbleAlignment alignment, {AdditionalConfigurations? additionalConfigurations}) {
           return const Placeholder();
       };
       ```
     </Tab>
   </Tabs>

5. **Footer Widget**

   The `footerView` property allows you to assign a custom Footer widget to the MessageBubble. By default, it displays the receipt and timestamp.

   <Tabs>
     <Tab title="Dart">
       ```dart theme={null}
       cometChatMessageTemplate.footerView = (BaseMessage baseMessage, BuildContext buildContext, BubbleAlignment alignment) {
           return const Placeholder();
       };
       ```
     </Tab>
   </Tabs>

6. **Bottom Widget**

   The `bottomView` property allows you to assign a custom Bottom widget to the MessageBubble.By defuault is has buttons such as link previews or a 'load more' button for long messages.

   <Tabs>
     <Tab title="Dart">
       ```dart theme={null}
       cometChatMessageTemplate.bottomView = (BaseMessage baseMessage, BuildContext buildContext, BubbleAlignment alignment) {
           return const Placeholder();
       };
       ```
     </Tab>
   </Tabs>

7. **Bubble Widget**

   The `bubbleView` property allows you to assign a custom Bubble widget to the MessageBubble. By default, headerView, contentView, and footerView together form a message bubble.

   <Tabs>
     <Tab title="Dart">
       ```dart theme={null}
       cometChatMessageTemplate.bubbleView = (BaseMessage baseMessage, BuildContext buildContext, BubbleAlignment alignment) {
           return const Placeholder();
       };
       ```
     </Tab>
   </Tabs>

8. **Options**

   The `options` lets you set the list of actions that a user can perform on a message. This includes actions like reacting to, editing, or deleting a message.

   <Tabs>
     <Tab title="Dart">
       ```dart theme={null}
       cometChatMessageTemplate.options = (User loggedInUser, BaseMessage messageObject, BuildContext context, Group? group) {
           return <CometChatMessageOption>[];
       };
       ```
     </Tab>
   </Tabs>

9. **Status Info Widget**

   The `statusInfoView` property allows you to assign a custom status info widget to the MessageBubble. By default, it displays the timestamp and read receipt under the content view.

   <Tabs>
     <Tab title="Dart">
       ```dart theme={null}
       cometChatMessageTemplate.statusInfoView = (BaseMessage baseMessage, BuildContext buildContext, BubbleAlignment alignment) {
           return const Placeholder();
       };
       ```
     </Tab>
   </Tabs>

10. **Thread Widget**

    The `threadView` property allows you to assign a custom thread widget to the MessageBubble. This is displayed at the bottom of the bubble for threaded messages.

    <Tabs>
      <Tab title="Dart">
        ```dart theme={null}
        cometChatMessageTemplate.threadView = (BaseMessage baseMessage, BuildContext buildContext, BubbleAlignment alignment) {
            return const Placeholder();
        };
        ```
      </Tab>
    </Tabs>

11. **Reply Widget**

    The `replyView` property allows you to assign a custom reply widget to the MessageBubble. This is displayed at the top of the bubble when replying to a message.

    <Tabs>
      <Tab title="Dart">
        ```dart theme={null}
        cometChatMessageTemplate.replyView = (BaseMessage baseMessage, BuildContext buildContext, BubbleAlignment alignment, {AdditionalConfigurations? additionalConfigurations}) {
            return const Placeholder();
        };
        ```
      </Tab>
    </Tabs>

## Customization

Let's dive into how you can use the [properties](#properties) of MessageTemplate to customize an existing template or add a new one to the [MessageList](/ui-kit/flutter/v5/message-list) Widget.

#### Header widget

The `headerView` method of MessageTemplate allows you to add custom widgets to the header of your message bubbles.

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
      CometChatMessageList(
        group: group, // Group object
        templates: [
          CometChatMessageTemplate(
              type: MessageTypeConstants.text,
              // Define the template type
              category: MessageCategoryConstants.message,
              // Define the template category
              headerView: (BaseMessage baseMessage, BuildContext buildContext,
                  BubbleAlignment alignment) {
                return Text(
                  "${baseMessage.sender?.name}• 🗓️ In meeting",
                  style: TextStyle(
                      color: Color(0xFF6852D6),
                      fontSize: 14.4,
                      fontWeight: FontWeight.w500,
                      letterSpacing: 0),
                ); // Replace this placeholder Widget with your custom Widget
              }),
        ],
      );
    ```
  </Tab>
</Tabs>

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/2JiXkJ8lq6PmPGlJ/images/6be84914-message_template_header_view-bf5b47764f19f9ada410fcfe240c7bbe.png?fit=max&auto=format&n=2JiXkJ8lq6PmPGlJ&q=85&s=af044198058e7e7323cf5534a7164c1c" width="2560" height="480" data-path="images/6be84914-message_template_header_view-bf5b47764f19f9ada410fcfe240c7bbe.png" />
</Frame>

***

#### Content widget

The `contentView` method of MessageTemplate allows you to add a custom widget to the content of your message bubbles.

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
      CometChatMessageList(
          group: group, // Group object
          templates: [
            CometChatMessageTemplate(
                type: "image",
                category: "message",
                contentView: (message, context, alignment,
                    {AdditionalConfigurations? additionalConfigurations}) {
                  if (message is! MediaMessage) {
                    return const SizedBox();
                  }
                  return Wrap(
                    direction: Axis.vertical,
                    crossAxisAlignment: WrapCrossAlignment.center,
                    children: [
                      CometChatImageBubble(
                        imageUrl: message.attachment?.fileUrl,
                        metadata: message.metadata,
                        key: UniqueKey(),
                      ),
                      TextButton(
                          onPressed: () {
                            //Navigate to screen with transaction features to purchase the image
                          },
                          child: Text(
                            "Buy Now",
                            style: TextStyle(
                                color: alignment == BubbleAlignment.left
                                    ? Color(0xFF6852D6)
                                    : Colors.white,
                                fontSize: 14,
                                fontWeight: FontWeight.w500),
                          ),
                          style: TextButton.styleFrom(
                            padding: EdgeInsets.zero,
                          ))
                    ],
                  );
                })
          ]);
    ```
  </Tab>
</Tabs>

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/OOBJyP9hM0C-rAe_/images/dcb14678-message_template_content_view-c24a6ea92a4b25a7c0d8e190f7787817.png?fit=max&auto=format&n=OOBJyP9hM0C-rAe_&q=85&s=fd6ff333c57b0105091a15174c910496" width="2560" height="1600" data-path="images/dcb14678-message_template_content_view-c24a6ea92a4b25a7c0d8e190f7787817.png" />
</Frame>

***

#### Bottom Widget

The `bottomView` property of MessageTemplate allows you to add a custom button widget to your message bubbles.

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatMessageList(
        group: group, // Group object
        templates: [
          CometChatMessageTemplate(
            type: MessageTypeConstants.text,
            // Define the template type
            category: MessageCategoryConstants.message,
            // Define the template category
            bottomView: (BaseMessage baseMessage, BuildContext buildContext,
                BubbleAlignment alignment) {
              return Container(
                decoration: BoxDecoration(
                  color: Color(0xFFF44649).withOpacity(.2),
                  borderRadius: BorderRadius.circular(12),
                ),
                child: Row(
                  children: [
                    Icon(
                      Icons.warning,
                      color: Color(0xFFF44649),
                      size: 12,
                    ),
                    Text(
                      "According to guidelines you cannot share contact",
                      style: TextStyle(
                          color: Color(0xFFF44649),
                          fontSize: 12,
                          fontWeight: FontWeight.w400,
                          letterSpacing: 0),
                    )
                  ],
                ),
              );
            },
          ),
        ],
      )
    ```
  </Tab>
</Tabs>

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/FGBCGWXGo5d9bVxR/images/c457f058-message_template_bottom_view-00455d8f124bbefd1884401bf7291682.png?fit=max&auto=format&n=FGBCGWXGo5d9bVxR&q=85&s=80af3f153726f1e85e9860fafb941442" width="2560" height="480" data-path="images/c457f058-message_template_bottom_view-00455d8f124bbefd1884401bf7291682.png" />
</Frame>

***

#### Footer Widget

The `footerView` property of MessageTemplate allows you to add a footer widget to your message bubbles.

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
       CometChatMessageList(
          group: group, // Group object
          templates: [
            CometChatMessageTemplate(
              // Define the template type
              type: MessageTypeConstants.text,
              // Define the template category
              category: MessageCategoryConstants.message,
              // override the default status info view to hide that date time and read receipt
              statusInfoView: (baseMessage, context, alignment) {
                return const SizedBox(height: 11);
              },
              // Define the footer view which would show the date time and read receipt
              footerView: (baseMessage, context, alignment,
                  {additionalConfigurations}) {
                return _getStatusInfoView(
                    alignment,
                    baseMessage,
                    baseMessage.sender?.uid == CometChatUIKit.loggedInUser?.uid,
                    context);
              },
            ),
          ],
        );
    ```
  </Tab>

  <Tab title="Status Info View">
    ```dart theme={null}
    Widget _getStatusInfoView(BubbleAlignment alignment, BaseMessage message,
          bool showReceipt, BuildContext context) {
        return Container(
          padding: EdgeInsets.only(
            left: 0,
            top: 0,
            bottom: 4,
          ),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              Container(
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    getTime(message),
                    if (showReceipt)
                      getReceiptIcon(message, CometChatUIKit.loggedInUser),
                  ],
                ),
              ),
            ],
          ),
        );
      }

      Widget getTime(BaseMessage messageObject) {
        if (messageObject.sentAt == null) {
          return const SizedBox();
        }

        DateTime lastMessageTime = messageObject.sentAt!;
        return CometChatDate(
            date: lastMessageTime,
            pattern: DateTimePattern.timeFormat,
            style: CometChatDateStyle(
              backgroundColor: Colors.transparent,
              textStyle: TextStyle(
                  color: Color(0xFF727272),
                  fontSize: 14.4,
                  fontWeight: FontWeight.w400,
                  letterSpacing: 0),
              border: Border.all(
                color: Colors.transparent,
                width: 0,
              ),
            ));
      }

      Widget getReceiptIcon(BaseMessage message, User? loggedInUser) {
        ReceiptStatus status = MessageReceiptUtils.getReceiptStatus(message);

        return Padding(
            padding: EdgeInsets.only(right: 8),
            child: CometChatReceipt(
              status: status,
              size: 16,
              style: CometChatMessageReceiptStyle(
                deliveredIconColor: Color(0xFF858585),
                readIconColor: Color(0xFF56E8A7),
                sentIconColor: Color(0xFF858585),
                waitIconColor: Color(0xFF858585),
              ),
            ));
      }
    ```
  </Tab>
</Tabs>

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/ubfBSdV1t6rmjxeA/images/89d8cb29-message_template_status_info_view-b2e5bc4e6139f9b2d2ce69d42826751e.png?fit=max&auto=format&n=ubfBSdV1t6rmjxeA&q=85&s=4aa46274dbe4ae4c4899abb01cab33dd" width="2560" height="648" data-path="images/89d8cb29-message_template_status_info_view-b2e5bc4e6139f9b2d2ce69d42826751e.png" />
</Frame>

***

#### Bubble Widget

The `bubbleView` property of MessageTemplate allows you to add a bubble widget to your message bubbles.

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
       CometChatMessageList(
          user: user, // User object
          group: group, // Group object
          templates: [
            CometChatMessageTemplate(
              type: "text",
              category: "message",
              bubbleView: (baseMessage, context, alignment,
                  {additionalConfigurations}) {
                return Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Column(
                    crossAxisAlignment: alignment == BubbleAlignment.right
                        ? CrossAxisAlignment.end
                        : CrossAxisAlignment.start,
                    children: [
                      CustomPaint(
                        size: Size(260, 100),
                        painter: ChatBubblePainter(
                            text: (baseMessage as TextMessage).text,
                            alignment: alignment,
                            color: alignment == BubbleAlignment.right
                                ? Color(0xFF6852D6)
                                : Color(0xFFE8E8E8)),
                      ),
                      _getStatusInfoView(
                          alignment,
                          baseMessage,
                          baseMessage.sender?.uid ==
                              CometChatUIKit.loggedInUser?.uid,
                          context)
                    ],
                  ),
                );
              },
            )
          ],
        );
    ```
  </Tab>

  <Tab title="Custom Chat Bubble">
    ```dart theme={null}
    class ChatBubblePainter extends CustomPainter {
      ChatBubblePainter({required this.text, this.color, this.alignment});

      final String text;
      final Color? color;

      final BubbleAlignment? alignment;

      @override
      void paint(Canvas canvas, Size size) {
        Paint paint = Paint()
          ..color = color ?? Colors.blue
          ..style = PaintingStyle.fill;

        Path path = Path();
        path.moveTo(0, 0);
        path.lineTo(size.width, 0);
        if (alignment == BubbleAlignment.right) {
          path.lineTo(size.width, size.height);
          path.lineTo(size.width * .9, size.height * .8);
          path.lineTo(0, size.height * .8);
        } else {
          path.lineTo(size.width, size.height * .8);
          path.lineTo(size.width * .1, size.height * .8);
          path.lineTo(0, size.height);
        }
        path.close();

        canvas.drawPath(path, paint);

        var style = TextStyle(
            color: alignment == BubbleAlignment.right ? Colors.white : Colors.black,
            fontSize: 20);

        final ParagraphBuilder paragraphBuilder = ParagraphBuilder(ParagraphStyle(
          fontSize: style.fontSize,
          fontFamily: style.fontFamily,
          fontStyle: style.fontStyle,
          fontWeight: style.fontWeight,
          textAlign: TextAlign.justify,
        ))
          ..pushStyle(style.getTextStyle())
          ..addText(text);
        final Paragraph paragraph = paragraphBuilder.build()
          ..layout(ParagraphConstraints(width: size.width));
        canvas.drawParagraph(paragraph, Offset(55, 25));
      }

      @override
      bool shouldRepaint(covariant CustomPainter oldDelegate) {
        return oldDelegate != this;
      }
    }
    ```
  </Tab>

  <Tab title="Status Info View">
    ```dart theme={null}
    Widget _getStatusInfoView(BubbleAlignment alignment, BaseMessage message,
          bool showReceipt, BuildContext context) {
        return Container(
          padding: EdgeInsets.only(
            left: 0,
            top: 0,
            bottom: 4,
          ),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              Container(
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    getTime(message),
                    if (showReceipt)
                      getReceiptIcon(message, CometChatUIKit.loggedInUser),
                  ],
                ),
              ),
            ],
          ),
        );
      }

      Widget getTime(BaseMessage messageObject) {
        if (messageObject.sentAt == null) {
          return const SizedBox();
        }

        DateTime lastMessageTime = messageObject.sentAt!;
        return CometChatDate(
            date: lastMessageTime,
            pattern: DateTimePattern.timeFormat,
            style: CometChatDateStyle(
              backgroundColor: Colors.transparent,
              textStyle: TextStyle(
                  color: Color(0xFF727272),
                  fontSize: 14.4,
                  fontWeight: FontWeight.w400,
                  letterSpacing: 0),
              border: Border.all(
                color: Colors.transparent,
                width: 0,
              ),
            ));
      }

      Widget getReceiptIcon(BaseMessage message, User? loggedInUser) {
        ReceiptStatus status = MessageReceiptUtils.getReceiptStatus(message);

        return Padding(
            padding: EdgeInsets.only(right: 8),
            child: CometChatReceipt(
              status: status,
              size: 16,
              style: CometChatMessageReceiptStyle(
                deliveredIconColor: Color(0xFF858585),
                readIconColor: Color(0xFF56E8A7),
                sentIconColor: Color(0xFF858585),
                waitIconColor: Color(0xFF858585),
              ),
            ));
      }
    ```
  </Tab>
</Tabs>

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/fxK75AS6FzDL1Oqo/images/b67f8f0e-message_template_bubble_view-8ab5019e5a320fdc115a8959df2c5207.png?fit=max&auto=format&n=fxK75AS6FzDL1Oqo&q=85&s=0197403136fe649debe2f77fac938210" width="2560" height="648" data-path="images/b67f8f0e-message_template_bubble_view-8ab5019e5a320fdc115a8959df2c5207.png" />
</Frame>

***

#### Options List

The `options` property in the MessageTemplate allows you to customize the options that appear in the action sheet when a message is long-pressed. By default, CometChat UI Kit provides a set of options like "Reply", "Edit", and "Delete".

However, if you wish to override or modify these options, you can use the `options` method and pass a list of `CometChatMessageOption`. This list of options will replace the default set.

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatMessageList(
        group: group, // Group object
        templates: [
          CometChatMessageTemplate(
            type: MessageTypeConstants.text,
            // Define the template type
            category: MessageCategoryConstants.message,
            options: (loggedInUser, messageObject, context, group,
                additionalConfigurations) {
              // Retrieve the existing options and add a new option to it
              final existingOptions = CometChatUIKit.getDataSource()
                  .getTextMessageOptions(loggedInUser, messageObject, context,
                      group, additionalConfigurations); // since we are updating the options for text message, we are using getTextMessageOptions
              return [
                CometChatMessageOption(
                    id: "refresh",
                    title: "Refresh",
                    icon: Icon(
                      Icons.refresh,
                      color: Color(0xFF6852D6),
                      size: 24,
                    ),
                    messageOptionSheetStyle: CometChatMessageOptionSheetStyle(
                      titleTextStyle: TextStyle(
                          color: Color(0xFF6852D6),
                          fontSize: 14,
                          fontWeight: FontWeight.w400,
                          letterSpacing: 0),
                    )),
                ...existingOptions,
              ];
            },
          ),
        ],
      )
    ```
  </Tab>
</Tabs>

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/XgQ9DxAoWn0btB5m/images/5dfa0ad6-message_template_options-3210c240eb01a9926b5c9fd056a5c9f6.png?fit=max&auto=format&n=XgQ9DxAoWn0btB5m&q=85&s=4c4a875ac5dc66a3192862a6b578668b" width="2560" height="1600" data-path="images/5dfa0ad6-message_template_options-3210c240eb01a9926b5c9fd056a5c9f6.png" />
</Frame>

***

## New Templates

You can create an entirely new template for custom messages is one of the powerful features of CometChat's MessageTemplate.

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
       CometChatMessageList(
          user: user, // User object
          group: group, // Group object
          messagesRequestBuilder: MessagesRequestBuilder()
            ..limit = 30
            ..types = [
              ...CometChatUIKit.getDataSource().getAllMessageTypes(),
              "contact"
            ] // Add the custom type here
            ..categories = CometChatUIKit.getDataSource().getAllMessageCategories(),
          templates: [
            CometChatMessageTemplate(
                type: "contact",
                // Define the template type̵
                category: MessageCategoryConstants.custom,
                // Define the template category
                contentView: (baseMessage, context, alignment,
                    {additionalConfigurations}) {
                  return Padding(
                    padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
                    child: Row(
                      children: [
                        CircleAvatar(
                          backgroundColor: Color(0xFFEDEAFA),
                          child: Icon(
                            Icons.person,
                            color: Colors.white,
                          ),
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        Text("Safiya Fareena",
                            style: TextStyle(
                              color: alignment == BubbleAlignment.right
                                  ? Colors.white
                                  : Colors.black,
                              fontSize: 14,
                            ))
                      ],
                    ),
                  );
                },
                bottomView: (baseMessage, context, alignment,
                    {additionalConfigurations}) {
                  return DecoratedBox(
                    decoration: BoxDecoration(
                        border: Border(
                            top: BorderSide(color: Color(0xFF7965DB), width: 1))),
                    child: ToggleButtons(
                      children: [
                        Padding(
                          padding: EdgeInsets.fromLTRB(20, 8, 0, 8),
                          child: Text("Add Contact",
                              style: TextStyle(
                                  color: alignment == BubbleAlignment.right
                                      ? Colors.white
                                      : Colors.black,
                                  fontSize: 14,
                                  fontWeight: FontWeight.w500)),
                        ),
                        VerticalDivider(
                          color: Color(0xFF7965DB),
                          width: 0,
                        ),
                        Padding(
                          padding: EdgeInsets.fromLTRB(0, 8, 20, 8),
                          child: Text("Message",
                              style: TextStyle(
                                  color: alignment == BubbleAlignment.right
                                      ? Colors.white
                                      : Colors.black,
                                  fontSize: 14,
                                  fontWeight: FontWeight.w500)),
                        )
                      ],
                      isSelected: [false, false, false],
                      renderBorder: false,
                    ),
                  );
                })
          ],
        );
    ```
  </Tab>
</Tabs>

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/7emVxEQ5MCxvzC60/images/203aee59-message_template_new_template-608f2523621f5f83525454382acc89b8.png?fit=max&auto=format&n=7emVxEQ5MCxvzC60&q=85&s=87456e930a2888f4d5c43ac4444a0241" width="2560" height="1600" data-path="images/203aee59-message_template_new_template-608f2523621f5f83525454382acc89b8.png" />
</Frame>
