> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-feature-react-native-sdk-quotedmessage-a.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Call Buttons

## Overview

The `Call Button` is a Component provides users with the ability to make calls, access call-related functionalities, and control call settings. Clicking this button typically triggers the call to be placed to the desired recipient.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-feature-react-native-sdk-quotedmessage-a/_FWwfJpY0a1-Jsg7/images/daaefbc1-55et9fX2XqpdHqxA4UAAAAACAXvO2Cn8xyPfrx48ffz527Nhvf3zg3wuUlUDn3abJAAAAAElFTkSuQmCC.png?fit=max&auto=format&n=_FWwfJpY0a1-Jsg7&q=85&s=915a9e652344a8fb0afbd7ac5cfb50a0" width="1280" height="232" data-path="images/daaefbc1-55et9fX2XqpdHqxA4UAAAAACAXvO2Cn8xyPfrx48ffz527Nhvf3zg3wuUlUDn3abJAAAAAElFTkSuQmCC.png" />
</Frame>

## Usage

### Integration

<Tabs>
  <Tab title="CallButtonDemo.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-javascript";
    import { CometChatCallButtons } from "@cometchat/chat-uikit-react";
    import React from "react";

    const CallButtonDemo = () => {
      const [chatUser, setChatUser] = React.useState<CometChat.User>();
      React.useEffect(() => {
        CometChat.getUser("uid").then((user) => {
          setChatUser(user);
        });
      }, []);
      return <CometChatCallButtons user={chatUser} />;
    };

    export default CallButtonDemo;
    ```
  </Tab>

  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CallButtonDemo } from "./CallButtonDemo";

    export default function App() {
      return (
        <div className="App">
          <div>
            <CallButtonDemo />
          </div>
        </div>
      );
    }
    ```
  </Tab>
</Tabs>

### Actions

[Actions](/ui-kit/react/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. onError

This action doesn't change the behavior of the component but rather listens for any errors that occur in the Call Button component.

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    import { CometChat } from "@cometchat/chat-sdk-javascript";
    import { CometChatCallButtons } from "@cometchat/chat-uikit-react";
    import React from "react";

    const CallButtonDemo = () => {
      const [chatUser, setChatUser] = React.useState<CometChat.User>();
      React.useEffect(() => {
        CometChat.getUser("uid").then((user) => {
          setChatUser(user);
        });
      }, []);

      const handleOnError = (error: CometChat.CometChatException) => {
        console.log("Your Custom on error actions", error);
      };

      return <CometChatCallButtons user={chatUser} onError={handleOnError} />;
    };

    export default CallButtonDemo;
    ```
  </Tab>

  <Tab title="JavaScript">
    ```js theme={null}
    import React, { useState, useEffect } from "react";
    import { CometChat } from "@cometchat/chat-sdk-javascript";
    import { CometChatCallButtons } from "@cometchat/chat-uikit-react";

    const CallButtonDemo = () => {
      const [chatUser, setChatUser] = useState(null);

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

      const handleOnError = (error) => {
        console.log("Your Custom on error actions", error);
      };

      return <CometChatCallButtons user={chatUser} onError={handleOnError} />;
    };

    export default CallButtonDemo;
    ```
  </Tab>
</Tabs>

***

### Filters

You can set `CallSettingsBuilder` in the Call Buttons Component to customise the calling experience. To know more about the filters available please refer to [CallSettingsBuilder](/sdk/javascript/direct-call#settings).

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    import { CometChat } from "@cometchat/chat-sdk-javascript";
    import { CometChatCallButtons } from "@cometchat/chat-uikit-react";
    import React from "react";

    const CallButtonDemo = () => {
      const [chatUser, setChatUser] = React.useState<CometChat.User>();

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

      const getCallSettingsBuilder = (call: CometChat.Call) => {
        return new CometChatCalls.CallSettingsBuilder()
          .setIsAudioOnlyCall(
            call?.getType() === CometChatUIKitConstants.MessageTypes.audio
              ? true
              : false
          )
          .build();
      };

      return (
        <CometChatCallButtons
          user={chatUser}
          callSettingsBuilder={getCallSettingsBuilder}
        />
      );
    };

    export default CallButtonDemo;
    ```
  </Tab>

  <Tab title="JavaScript">
    ```js theme={null}
    import React, { useState, useEffect } from "react";
    import { CometChat } from "@cometchat/chat-sdk-javascript";
    import { CometChatCallButtons } from "@cometchat/chat-uikit-react";

    const CallButtonDemo = () => {
      const [chatUser, setChatUser] = useState(null);

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

      const getCallSettingsBuilder = (call) => {
        return new CometChatCalls.CallSettingsBuilder()
          .setIsAudioOnlyCall(
            call?.getType() === CometChatUIKitConstants.MessageTypes.audio
              ? true
              : false
          )
          .build();
      };

      return (
        <CometChatCallButtons
          user={chatUser}
          callSettingsBuilder={getCallSettingsBuilder}
        />
      );
    };

    export default CallButtonDemo;
    ```
  </Tab>
</Tabs>

***

### Events

[Events](/ui-kit/react/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 list of events emitted by the `Call Buttons` component is as follows.

| Event              | Description                                                                                               |
| ------------------ | --------------------------------------------------------------------------------------------------------- |
| **ccCallRejected** | This event is triggered when the initiated call is rejected by the receiver.                              |
| **ccCallEnded**    | This event is triggered when the initiated call successfully ends.                                        |
| **ccOutgoingCall** | This event is triggered when the user initiates a voice/video call.                                       |
| **ccMessageSent**  | This event is triggered when the sent message is in transit and also when it is received by the receiver. |

***

<Tabs>
  <Tab title="Add Listener">
    ```tsx theme={null}
    const ccCallRejected = CometChatCallEvents.ccCallRejected.subscribe(
      (call: CometChat.Call) => {
        //Your Code
      }
    );

    const ccCallEnded = CometChatCallEvents.ccCallEnded.subscribe(
      (call: CometChat.Call) => {
        //Your Code
      }
    );

    const ccOutgoingCall = CometChatCallEvents.ccOutgoingCall.subscribe(
      (call: CometChat.Call) => {
        //Your Code
      }
    );

    const ccMessageSent = CometChatMessageEvents.ccMessageSent.subscribe(() => {
      //Your Code
    });
    ```
  </Tab>
</Tabs>

***

<Tabs>
  <Tab title="Remove Listener">
    ```tsx theme={null}
    ccCallRejected?.unsubscribe();

    ccCallEnded?.unsubscribe();

    ccOutgoingCall?.unsubscribe();

    ccMessageSent?.unsubscribe();
    ```
  </Tab>
</Tabs>

***

## Customization

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

### Style

Using CSS you can customize the look and feel of the component in your app like the color, size, shape, and fonts.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-feature-react-native-sdk-quotedmessage-a/nV1KIvn8ZxahSHvn/images/3b154ea9-wPyMSRehgR7CgAAAAAElFTkSuQmCC.png?fit=max&auto=format&n=nV1KIvn8ZxahSHvn&q=85&s=4b86571f37123196dec2a58b1881d5b2" width="1280" height="231" data-path="images/3b154ea9-wPyMSRehgR7CgAAAAAElFTkSuQmCC.png" />
</Frame>

**Example**

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    import { CometChat } from "@cometchat/chat-sdk-javascript";
    import { CometChatCallButtons } from "@cometchat/chat-uikit-react";
    import React from "react";

    const CallButtonDemo = () => {
      const [chatUser, setChatUser] = React.useState<CometChat.User>();
      React.useEffect(() => {
        CometChat.getUser("uid").then((user) => {
          setChatUser(user);
        });
      }, []);

      return <CometChatCallButtons user={chatUser} />;
    };

    export default CallButtonDemo;
    ```
  </Tab>

  <Tab title="JavaScript">
    ```js theme={null}
    import React, { useState, useEffect } from "react";
    import { CometChat } from "@cometchat/chat-sdk-javascript";
    import { CometChatCallButtons } from "@cometchat/chat-uikit-react";

    const CallButtonDemo = () => {
      const [chatUser, setChatUser] = useState(null);

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

      return <CometChatCallButtons user={chatUser} />;
    };

    export default CallButtonDemo;
    ```
  </Tab>

  <Tab title="css">
    ```css theme={null}
    .cometchat-call-button {
      display: flex;
      width: 183px;
      height: 64px;
      padding: 8px 16px;
      justify-content: center;
      align-items: center;
      border-bottom: 1px solid #f5f5f5;
      background: #fff;
    }

    .cometchat-call-button .cometchat-call-button__voice,
    .cometchat-call-button .cometchat-call-button__video {
      width: auto;
      height: auto;
    }

    .cometchat .cometchat-button {
      display: flex;
      width: 52px;
      height: 40px;
      justify-content: center;
      padding: 8px 20px;
      align-items: center;
      border-radius: 8px;
      border: 1px solid #e8e8e8;
      background: #edeafa;
    }

    .cometchat .cometchat-button:hover {
      background-color: #edeafa;
    }

    .cometchat-call-button .cometchat-call-button__video .cometchat-button__icon,
    .cometchat-call-button .cometchat-call-button__voice .cometchat-button__icon {
      width: 24px;
      height: 24px;
      flex-shrink: 0;
      background-color: #6852d6;
    }
    ```
  </Tab>
</Tabs>

***

## Configurations

Configurations offer the ability to customize the properties of each component within a Composite Component. `CallButtons` component renders [CometChatOutgoingCall](/ui-kit/react/outgoing-call) component.

#### Outgoing Call

You can customize the properties of the `CometChatOutgoingCall` component by making use of the `OutgoingCallConfiguration`. Below properties are available in `OutgoingCallConfiguration`.

| Property                   | Description                                                                     | Code                                                                               |
| -------------------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| **User**                   | Sets the user object for Call Buttons                                           | `user={chatUser}`                                                                  |
| **Group**                  | Used to set the group object for Call Buttons                                   | `group={chatGroup}`                                                                |
| **Custom Sound**           | Specifies a custom sound to play for outgoing calls.                            | `customSoundForCalls='Your Custom Sound For Calls'`                                |
| **Disable Sound**          | Disables the sound of outgoing calls.                                           | `disableSoundForCalls={false}`                                                     |
| **On Error**               | Callback function triggered when an error occurs in the call buttons component. | `onError={(error: CometChat.CometChatException)=>{ console.log('error', error) }}` |
| **Cancel Call Clicked**    | Callback function triggered when the cancel button is clicked.                  | `onCloseClicked={()=>{console.log("Outgoing call canceled")}}`                     |
| **Title View**             | This prop renders the custom title view for the outgoing call.                  | `titleView={<>Custom Title View</>}`                                               |
| **Sub Title View**         | This prop renders the custom sub title view for the outgoing call.              | `subtitleView={<>Custom Sub Title View</>}`                                        |
| **Avatar View**            | This prop renders the custom avatar view for the outgoing call.                 | `avatarView={<>Custom Avatar View</>}`                                             |
| **Cancel Button View**     | This prop renders the custom cancel-call button view for the outgoing call.     | `cancelButtonView={<>Custom Cancel Button View</>}`                                |
| **Hide Video Call Button** | Used to hide the video call button.                                             | `hideVideoCallButton={true}`                                                       |
| **Hide Voice Call Button** | Used to hide the voice call button.                                             | `hideVoiceCallButton={true}`                                                       |

You can refer to [CometChatOutgoingCall](/ui-kit/react/outgoing-call) component to know more about each of the above properties.

***
