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

# Button Element

> Button Element — CometChat documentation.

## Constructor

| Name       | Type                                             | Description                                                              |
| ---------- | ------------------------------------------------ | ------------------------------------------------------------------------ |
| elementId  | string                                           | A unique identifier for the button element                               |
| action     | APIAction \| URLNavigationAction \| CustomAction | The action to be performed when the button is clicked                    |
| buttonText | string                                           | The text to be displayed on the button. Default value is an empty string |

## Class Usage

How to create an instance of the ButtonElement class:

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    // Create an instance of APIAction

    let apiAction = new APIAction("https://example.com/api", "POST");

    // Create a new instance of ButtonElement

    let buttonElement = new ButtonElement("1", apiAction, "Submit");
    ```
  </Tab>
</Tabs>

In this example, a new instance of ButtonElement is created with an elementId "1", an APIAction as an action, and "Submit" as the button text.

## Key Properties and Methods

### Button Interaction Property

The setDisableAfterInteracted() method allows changing this property. It accepts a boolean value indicating whether the button should be disabled after it is interacted with.

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    let apiAction = new APIAction("https://example.com/api", "POST");
    let buttonElement = new ButtonElement("1", apiAction, "Submit");
    buttonElement.setDisableAfterInteracted(false);
    ```
  </Tab>
</Tabs>

## Example

Below is an example that showcases the creation and manipulation of an instance of ButtonElement:

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    // Create an instance of APIAction

    let apiAction = new APIAction("https://example.com/api", "POST");

    // Create a new instance of ButtonElement

    let buttonElement = new ButtonElement("1", apiAction, "Submit");

    buttonElement.setDisableAfterInteracted(false);
    ```
  </Tab>
</Tabs>

In this example, a new instance of the ButtonElement is created. The button text, action and interaction property are retrieved, updated, and logged. Then a new ButtonElement instance is made from a JSON object and its button text is retrieved and logged.
