> ## 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 Header

> Message Header — CometChat documentation.

`MessageHeader` is a [Component](/ui-kit/react-native/v4/components-overview#components) that showcases the [User](/sdk/react-native/users-overview) or [Group](/sdk/react-native/groups-overview) details in the toolbar. Furthermore, it also presents a typing indicator and a back navigation button for ease of use.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/OOBJyP9hM0C-rAe_/images/da401f4c-message_header_overview_cometchat_screens-2e1d1689df68984d9471e8f960aa0cca.png?fit=max&auto=format&n=OOBJyP9hM0C-rAe_&q=85&s=5b69dea86f5496e1aa07f9a2ffbcff99" alt="Image" width="4498" height="3120" data-path="images/da401f4c-message_header_overview_cometchat_screens-2e1d1689df68984d9471e8f960aa0cca.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/fxK75AS6FzDL1Oqo/images/bb404705-message_header_overview_cometchat_screens-f4a3e0d4f829e459c1634500209e4888.png?fit=max&auto=format&n=fxK75AS6FzDL1Oqo&q=85&s=b8c5f069cc91e3d4411fc5348c898b71" alt="Image" width="4498" height="3120" data-path="images/bb404705-message_header_overview_cometchat_screens-f4a3e0d4f829e459c1634500209e4888.png" />
  </Tab>
</Tabs>

The `MessageHeader` is comprised of the following components:

| Components                                              | Description                                                                                                                                    |
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| [ListItem Component](/ui-kit/react-native/v4/list-item) | This component’s view consists of avatar, status indicator , title, and subtitle. The fields are then mapped with the SDK’s user, group class. |
| Back Button                                             | BackButton that allows users to navigate back from the current activity or screen to the previous one                                          |

## Usage

### Integration

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from '@cometchat/chat-sdk-react-native';
    import { CometChatMessageHeader, MessageHeaderStyleInterface } from '@cometchat/chat-uikit-react-native';
    import React from 'react';

    function App(): React.JSX.Element {
        const [chatUser, setChatUser] = React.useState<CometChat.User| undefined>();

        React.useEffect(() => {
            CometChat.getUser("uid").then((user) => {
                setChatUser(user);
            })
        }, []);

      const messageHeaderStyle : MessageHeaderStyleInterface = {
         backgroundColor: "#c7caed"
      }

      return (
        <>
            { chatUser && <CometChatMessageHeader
                 user={chatUser}
                 style={messageHeaderStyle}
              />
             }
        </>
      );
    }
    ```
  </Tab>
</Tabs>

### Actions

[Actions](/ui-kit/react-native/v4/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

##### 1. OnBack

`OnBack` is triggered when you click on the back button of the Message Header component. You can override this action using the following code snippet.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from '@cometchat/chat-sdk-react-native';
    import { CometChatMessageHeader, MessageHeaderStyleInterface } from '@cometchat/chat-uikit-react-native';
    import React from 'react';

    function App(): React.JSX.Element {
        const [chatUser, setChatUser] = React.useState<CometChat.User| undefined>();

        React.useEffect(() => {
            CometChat.getUser("uid").then((user) => {
                setChatUser(user);
            })
        }, []);

      let messageHeaderStyle : MessageHeaderStyleInterface = {
         backgroundColor: "#c7caed"
      }

      const onBackHandler = () => {
        //code
      }

      return (
        <>
            { chatUser && <CometChatMessageHeader
                 user={chatUser}
                 style={messageHeaderStyle}
                 onBack={onBackHandler}
              />
             }
        </>
      );
    }
    ```
  </Tab>
</Tabs>

***

### Filters

**Filters** allow you to customize the data displayed in a list within a `Component`. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using `RequestBuilders` of Chat SDK.

The `MessageHeader` component does not have any exposed filters.

### Events

[Events](/ui-kit/react-native/v4/components-overview#events) are emitted by a `Component`. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.

The `MessageHeader` component does not produce any events.

## Customization

To fit your app's design requirements, you can customize the appearance of the conversation component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

### Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.

##### 1. MessageHeader Style

To customize the appearance, you can assign a `MessageHeaderStyle` object to the `MessageHeader` component.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from '@cometchat/chat-sdk-react-native';
    import { CometChatMessageHeader, MessageHeaderStyleInterface } from '@cometchat/chat-uikit-react-native';
    import React from 'react';

    function App(): React.JSX.Element {
        const [chatUser, setChatUser] = React.useState<CometChat.User| undefined>();

        React.useEffect(() => {
            CometChat.getUser("uid").then((user) => {
                setChatUser(user);
            })
        }, []);

      const messageHeaderStyle : MessageHeaderStyleInterface = {
         backgroundColor: "#c7caed"
      }

      return (
        <>
            { chatUser && <CometChatMessageHeader
                 user={chatUser}
                 style={messageHeaderStyle}
              />
             }
        </>
      );
    }
    ```
  </Tab>
</Tabs>

The properties exposed by `MessageHeaderStyle` are as follows:

| Property                 | Type                 | Description                                              |
| ------------------------ | -------------------- | -------------------------------------------------------- |
| backgroundColor          | string               | Sets the background colour for message header            |
| width                    | string \| number     | Sets the width for message header                        |
| height                   | string \| number     | Sets the height for message header                       |
| border                   | BorderStyleInterface | Sets the border colour for message header                |
| borderRadius             | number               | sets the border radius for message header                |
| backIconTint             | string               | Sets the tint colour for back icon for message header    |
| typingIndicatorTextColor | string               | Sets the typing indicator text colour for message header |
| typingIndicatorTextFont  | FontStyleInterface   | Sets the typing indicator text font for message header   |
| onlineStatusColor        | string               | Sets the online status colour for message header         |
| subtitleTextColor        | string               | Sets the subtitle colour for message header              |
| subtitleTextFont         | FontStyleInterface   | Sets the subtitle font for message header                |

##### 2. Avatar Style

If you want to apply customized styles to the `Avatar` component within the `MessageHeader` Component, you can use the following code snippet. For more information you can refer [Avatar Styles](/ui-kit/react-native/v4/avatar#avatarstyleinterface).

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from '@cometchat/chat-sdk-react-native';
    import { CometChatMessageHeader, BorderStyleInterface, AvatarStyleInterface } from '@cometchat/chat-uikit-react-native';
    import React from 'react';

    function App(): React.JSX.Element {
        const [chatUser, setChatUser] = React.useState<CometChat.User| undefined>();

        React.useEffect(() => {
            CometChat.getUser("uid").then((user) => {
                setChatUser(user);
            })
        }, []);

        const messageHeaderStyle : MessageHeaderStyleInterface = {
           backgroundColor: "#c7caed"
        }

        const borderStyle : BorderStyleInterface = {
           borderStyle: "solid",
           borderColor: "#6851D6",
           borderWidth: 1
        }

        const avatarStyle : AvatarStyleInterface = {
         border: borderStyle
        }

        return (
          <>
            { chatUser && <CometChatMessageHeader
                 user={chatUser}
                 style={messageHeaderStyle}
                 avatarStyle={avatarStyle}
              />
             }
          </>
        );
    }
    ```
  </Tab>
</Tabs>

##### 3. ListItem Style

If you want to apply customized styles to the `ListItemStyle` component within the `MessageHeader` Component, you can use the following code snippet. For more information, you can refer [ListItem Styles](/ui-kit/react-native/v4/list-item#listitemstyle).

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from '@cometchat/chat-sdk-react-native';
    import { CometChatMessageHeader, MessageHeaderStyleInterface } from '@cometchat/chat-uikit-react-native';
    import React from 'react';

    function App(): React.JSX.Element {
        const [chatUser, setChatUser] = React.useState<CometChat.User| undefined>();

        React.useEffect(() => {
            CometChat.getUser("uid").then((user) => {
                setChatUser(user);
            })
        }, []);

        const messageHeaderStyle : MessageHeaderStyleInterface = {
           backgroundColor: "#c7caed"
        }

        const listItemStyle : ListItemStyleInterface = {
           backgroundColor: "transparent",
           titleColor:"#6851D6",
        };

        return (
          <>
            { chatUser && <CometChatMessageHeader
                 user={chatUser}
                 style={messageHeaderStyle}
                 listItemStyle={listItemStyle}
              />
             }
          </>
        );
    }
    ```
  </Tab>
</Tabs>

##### 4. StatusIndicator Style

If you want to apply customized styles to the `Status Indicator` component within the `MessageHeader` Component, you can use the following code snippet. For more information you can refer [StatusIndicator Styles](/ui-kit/react-native/v4/status-indicator).

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from '@cometchat/chat-sdk-react-native';
    import { CometChatMessageHeader, MessageHeaderStyleInterface, StatusIndicatorStyleInterface } from '@cometchat/chat-uikit-react-native';
    import React from 'react';

    function App(): React.JSX.Element {
        const [chatUser, setChatUser] = React.useState<CometChat.User| undefined>();

        React.useEffect(() => {
            CometChat.getUser("uid").then((user) => {
                setChatUser(user);
            })
        }, []);

        const messageHeaderStyle : MessageHeaderStyleInterface = {
           backgroundColor: "#c7caed"
        }

        const statusIndicatorStyle : StatusIndicatorStyleInterface= {
            backgroundColor: "red",
            height: 15,
            width: 15,
            border: borderStyle,
            borderRadius: 100,
         };

        return (
          <>
            { chatUser && <CometChatMessageHeader
                 user={chatUser}
                 style={messageHeaderStyle}
                 statusIndicatorStyle={statusIndicatorStyle}
              />
             }
          </>
        );
    }
    ```
  </Tab>
</Tabs>

### Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.

Here is a code snippet demonstrating how you can customize the functionality of the Message Header component.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/mq8rEbFfi0JjKmkM/images/6454c803-message_header_functionality_cometchat_screens-a7952708e172158d75f56c928036bd03.png?fit=max&auto=format&n=mq8rEbFfi0JjKmkM&q=85&s=2407656e3356e718f4e66f7d15312ad1" alt="Image" width="4498" height="3120" data-path="images/6454c803-message_header_functionality_cometchat_screens-a7952708e172158d75f56c928036bd03.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/_MYSdWhXnUkTkjEH/images/489d5ece-message_header_functionality_cometchat_screens-0c36ba9cd015e0ab6527fda407d312c2.png?fit=max&auto=format&n=_MYSdWhXnUkTkjEH&q=85&s=6da4af28ad8c32155bf4a0c9756f1eb7" alt="Image" width="4498" height="3120" data-path="images/489d5ece-message_header_functionality_cometchat_screens-0c36ba9cd015e0ab6527fda407d312c2.png" />
  </Tab>
</Tabs>

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import {
      CometChatMessageHeader,
      MessageHeaderStyleInterface,
    } from "@cometchat/chat-uikit-react-native";
    import React from "react";

    function App(): React.JSX.Element {
      const [chatUser, setChatUser] = React.useState<CometChat.User | undefined>();

      React.useEffect(() => {
        CometChat.getUser("uid").then((user) => {
          setChatUser(user);
        });
      }, []);

      const messageHeaderStyle: MessageHeaderStyleInterface = {
        backgroundColor: "#c7caed",
      };

      return (
        <>
          {chatUser && (
            <CometChatMessageHeader
              user={chatUser}
              style={messageHeaderStyle}
              hideBackIcon={true}
            />
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>

Following is a list of customizations along with their corresponding code snippets:

| Property                 | Description                                                              | Code                                                                                                                                                                  |
| ------------------------ | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **user**                 | Used to pass user object of which header specific details will be shown  | `user={chatUser}`                                                                                                                                                     |
| **group**                | Used to pass group object of which header specific details will be shown | `group={chatGroup}`                                                                                                                                                   |
| **protectedGroupIcon**   | Used to set custom protected group icon                                  | `protectedGroupIcon={{uri: <image url>}}` OR `import customProtectedGroupIcon from "./customProtectedGroupIcon.svg"; ``protectedGroupIcon={customProtectedGroupIcon}` |
| **privateGroupIcon**     | Used to set custom private group icon                                    | `privateGroupIcon={{uri: <image url>}}` OR `import customPrivateGroupIcon from "./customPrivateGroupIcon.svg"; ``privateGroupIcon={customPrivateGroupIcon}`           |
| **hideBackIcon**         | Used to toggle back button visibility                                    | `hideBackhideBackIconButton={true}`                                                                                                                                   |
| **disableTyping**        | Used to enable disable typing indicators                                 | `disableTyping={true}`                                                                                                                                                |
| **disableUsersPresence** | Used to toggle functionality to show user's presence                     | `disableUsersPresence={true`                                                                                                                                          |

### Advanced

For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.

***

#### SubtitleView

By using the `SubtitleView` method, you can modify the SubtitleView to meet your specific needs.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from '@cometchat/chat-sdk-react-native';
    import { CometChatMessageHeader, MessageHeaderStyleInterface } from '@cometchat/chat-uikit-react-native';
    import React from 'react';

    function App(): React.JSX.Element {
        const [chatUser, setChatUser] = React.useState<CometChat.User| undefined>();

        React.useEffect(() => {
            CometChat.getUser("uid").then((user) => {
                setChatUser(user);
            })
        }, []);

      const messageHeaderStyle : MessageHeaderStyleInterface = {
         backgroundColor: "#c7caed"
      }

      function formatTime(timestamp: number) {
        const date = new Date(timestamp * 1000);
        return date.toLocaleString();
      }

      const getSubtitleView = () =>{
        return (
          <Text>{formatTime(chatUser!.getLastActiveAt())}</Text>
        )
      }

      return (
        <>
            { chatUser && <CometChatMessageHeader
                 user={chatUser}
                 style={messageHeaderStyle}
                 SubtitleView={getSubtitleView}
              />
             }
        </>
      );
    }
    ```
  </Tab>
</Tabs>

**Example**

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/xIG5VBdyNJ5cYSqE/images/d499bd41-message_header_set_subtitle_view_cometchat_screens-c6ab688be537bf2a5496d30e17ff9f9d.png?fit=max&auto=format&n=xIG5VBdyNJ5cYSqE&q=85&s=27fffcba504ccd2700526753054b78da" alt="Image" width="4498" height="3120" data-path="images/d499bd41-message_header_set_subtitle_view_cometchat_screens-c6ab688be537bf2a5496d30e17ff9f9d.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/PaxBG9I1yMoeQmt2/images/331c0823-message_header_set_subtitle_view_cometchat_screens-f5882a34260118961f9806cc8c24fb1d.png?fit=max&auto=format&n=PaxBG9I1yMoeQmt2&q=85&s=c7d1f52a4e0a2638075b705ae89e0c60" alt="Image" width="4498" height="3120" data-path="images/331c0823-message_header_set_subtitle_view_cometchat_screens-f5882a34260118961f9806cc8c24fb1d.png" />
  </Tab>
</Tabs>

***

#### BackButtonIcon

You can customize the Back Icon according to your specific requirements by using the `backButtonIcon` method.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import {
      CometChatMessageHeader,
      MessageHeaderStyleInterface,
    } from "@cometchat/chat-uikit-react-native";
    import React from "react";
    import BackArrow from "./back-arrow.png";

    function App(): React.JSX.Element {
      const [chatUser, setChatUser] = React.useState<CometChat.User | undefined>();

      React.useEffect(() => {
        CometChat.getUser("uid").then((user) => {
          setChatUser(user);
        });
      }, []);

      const messageHeaderStyle: MessageHeaderStyleInterface = {
        backgroundColor: "#c7caed",
      };

      return (
        <>
          {chatUser && (
            <CometChatMessageHeader
              user={chatUser}
              style={messageHeaderStyle}
              backButtonIcon={BackArrow}
            />
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>

**Example**

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/7emVxEQ5MCxvzC60/images/1ecd7063-message_header_set_back_button_cometchat_screens-73484c4246ceb4d0dad86f488028d5a6.png?fit=max&auto=format&n=7emVxEQ5MCxvzC60&q=85&s=86772f1998282ba8a66e6e25b896a271" alt="Image" width="4498" height="3120" data-path="images/1ecd7063-message_header_set_back_button_cometchat_screens-73484c4246ceb4d0dad86f488028d5a6.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/TO10Bmu50bb5qPTI/images/324ae2bc-message_header_set_back_button_cometchat_screens-af2614f816c457c37787411e84c0ad28.png?fit=max&auto=format&n=TO10Bmu50bb5qPTI&q=85&s=5d42df9ca617cdf0e5ed6339c08912c5" alt="Image" width="4498" height="3120" data-path="images/324ae2bc-message_header_set_back_button_cometchat_screens-af2614f816c457c37787411e84c0ad28.png" />
  </Tab>
</Tabs>

***

#### AppBarOptions

You can customize the Menu options to meet your specific needs by using the `AppBarOptions` method.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from '@cometchat/chat-sdk-react-native';
    import { CometChatMessageHeader, MessageHeaderStyleInterface } from '@cometchat/chat-uikit-react-native';
    import React from 'react';
    import Call from './Call.png';

    function App(): React.JSX.Element {
        const [chatUser, setChatUser] = React.useState<CometChat.User| undefined>();

        React.useEffect(() => {
            CometChat.getUser("uid").then((user) => {
                setChatUser(user);
            })
        }, []);

      const messageHeaderStyle : MessageHeaderStyleInterface = {
         backgroundColor: "#c7caed"
      }

      const appBarOptions = () =>{
        return (
          <Image source={Call} style={{ tintColor: '#6851D6', marginRight: 3 }} />
        )
      }

      return (
        <>
            { chatUser && <CometChatMessageHeader
                 user={chatUser}
                 style={messageHeaderStyle}
                 AppBarOptions={appBarOptions}
              />
             }
        </>
      );
    }
    ```
  </Tab>
</Tabs>

**Example**

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/2JiXkJ8lq6PmPGlJ/images/6f07b5ed-message_header_app_bar_cometchat_screens-8cb2583488088daa2c27fd551e4406e3.png?fit=max&auto=format&n=2JiXkJ8lq6PmPGlJ&q=85&s=bedb4051a5bc038d94f79256c1efc02c" alt="Image" width="4498" height="3120" data-path="images/6f07b5ed-message_header_app_bar_cometchat_screens-8cb2583488088daa2c27fd551e4406e3.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/mq8rEbFfi0JjKmkM/images/6a9f088d-message_header_app_bar_cometchat_screens-10b23bd2e43482c7cc6e5b331c390efb.png?fit=max&auto=format&n=mq8rEbFfi0JjKmkM&q=85&s=c271172b66eca13d291e0f1836c0a7fe" alt="Image" width="4498" height="3120" data-path="images/6a9f088d-message_header_app_bar_cometchat_screens-10b23bd2e43482c7cc6e5b331c390efb.png" />
  </Tab>
</Tabs>
