> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Button Element

> Button Element — CometChat documentation.

The `ButtonElement` class, inherited from the `BaseInteractiveElement` class, represents an interactive button element that can be added to a chat interface. It comprises of properties like button text and a flag indicating whether the button should be disabled after interaction.

### Constructor

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

### Class Usage

How to create an instance of the `ButtonElement` class:

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    // Create an instance of APIAction
    APIAction apiAction = new APIAction("https://example.com/api", "POST");

    // Create a new instance of ButtonElement
    ButtonElement buttonElement = new ButtonElement("1", "Submit", apiAction);
    ```
  </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.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    buttonElement.setDisableAfterInteracted(false);
    ```
  </Tab>
</Tabs>
