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

# Text Input Element

> Text Input Element — CometChat documentation.

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

## Class Usage

How to create an instance of the TextInputElement class:

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    let inputElement = new TextInputElement("1", "Name");
    ```
  </Tab>
</Tabs>

In the above example, a new instance of TextInputElement is created with the elementId "1" and the label "Name".

## Key Properties and Methods

### Maximum Lines for Text Input

The setMaxLines() method is used to set the maximum number of lines for a multi-line text input element, while getMaxLines() is used to retrieve the set value.

For example:

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    let inputElement = new TextInputElement("1", "Name");
    inputElement.setMaxLines(1); //set max lines
    ```
  </Tab>
</Tabs>

### Placeholder Text for the Input Element

The setPlaceholder() method is used to set placeholder text in the input field and getPlaceholder() is used to retrieve the placeholder text.

For instance:

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    let inputElement = new TextInputElement("1", "Name");
    inputElement.setPlaceholder("Enter your name");
    ```
  </Tab>
</Tabs>

### Default Value of the Input Element

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

For example:

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    let inputElement = new TextInputElement("1", "Name");
    inputElement.setDefaultValue("John Doe");
    ```
  </Tab>
</Tabs>

## Example

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

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    // Import the class
    import { TextInputElement } from "./TextInputElement";

    // Create a new instance of the class
    let inputElement = new TextInputElement("1", "Name");

    // Set the max lines
    inputElement.setMaxLines(1);

    // Set the placeholder text
    inputElement.setPlaceholder("Enter your name");

    // Set the default value
    inputElement.setDefaultValue("John Doe");
    ```
  </Tab>
</Tabs>
