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

# Single Select Element

> Single Select Element — CometChat documentation.

The `SingleSelectElement` class is utilised to create a single selection input element in a user interface.

### Constructor

| Name      | Type                   | Description                                                     |
| --------- | ---------------------- | --------------------------------------------------------------- |
| elementId | `string`               | This property in constructor accepts the Id for the element     |
| label     | `string`               | This property in constructor accepts the label for singleSelect |
| options   | `Array<OptionElement>` | This property in constructor accepts options for singleSelect   |

### Class Usage

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

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

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

    let optionsList = [option1, option2];

    let singleSelectElement = new SingleSelectElement("1", "Choose an option", optionsList);
    ```
  </Tab>
</Tabs>

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

### Key Properties and Methods

#### Default Value of the Input Element

The `setDefaultValue()` method sets the default value in the single select input, while the `getDefaultValue()` retrieves it.

For example:

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    singleSelectElement.setDefaultValue("1");
    ```
  </Tab>
</Tabs>

### Example

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

<Tabs>
  <Tab title="TypeScript">
    ```typescript 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 SingleSelectElement

    let singleSelectElement = new SingleSelectElement("1", "Choose an option", optionsList);

    // Set and get the default value

    singleSelectElement.setDefaultValue("1");
    ```
  </Tab>
</Tabs>
