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

# Checkbox Element

> Checkbox Element — CometChat documentation.

The CheckboxElement class aids in creating checkbox input elements in a user interface.

## Constructor

| Name      | Type                  | Description                                       |
| --------- | --------------------- | ------------------------------------------------- |
| elementId | string                | Accepts the ID for the element in the constructor |
| label     | string                | Accepts the label for checkbox in the constructor |
| options   | Array\<OptionElement> | Accepts options for checkbox in the constructor   |

## Class Usage

Here's how to create an instance of the CheckboxElement class:

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    let option1 = new OptionElement("Option 1", "1");

    let option2 = new OptionElement("Option 2", "2");

    let optionsList = [option1, option2];

    let checkboxElement = new CheckboxElement("1", "Choose options", optionsList);
    ```
  </Tab>
</Tabs>

In this example, a new instance of CheckboxElement is created with an elementId "1", a label "Choose options", and a list of two options.

## Key Properties and Methods

### Default Value of the Input Element

The setDefaultValue() method sets the default value(s) in the checkbox input, while the getDefaultValue() retrieves it.

For example

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    checkboxElement.setDefaultValue(["1", "2"]);
    ```
  </Tab>
</Tabs>

## Example

Here is an example that showcases the creation and manipulation of an instance of CheckboxElement:

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    // Create some options

    let option1 = new OptionElement("Option 1", "1");

    let option2 = new OptionElement("Option 2", "2");

    let optionsList = [option1, option2];

    // Create a new instance of CheckboxElement

    let checkboxElement = new CheckboxElement("1", "Choose options", optionsList);

    // Set and get the default value

    checkboxElement.setDefaultValue(["1", "2"]);
    ```
  </Tab>
</Tabs>
