> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# `<textarea>`

APISummary
`<textarea>` is used to create interactive input controls that allow users to input and edit multi-line text.

:::tip

This feature requires the client to add additional dependencies. Please refer to [More Elements](/next/guide/start/integrate-with-existing-apps.md) for the integration method.

:::

## Usage

### Basic

Below is a basic usage example of the `<textarea>` component:

**This is an example below: textarea**

**Bundle:** `dist/base.lynx.bundle` | Web: `dist/base.web.bundle`

```tsx {13-21}
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root, useState } from "@lynx-js/react";

const App = () => {
  const [inputContent, setInputContent] = useState("");

  return (
    <view style={{ linearOrientation: "vertical", width: "100%", height: "100%", padding: "20px" }}>
      <view style={{ width: "100%", padding: "10px", backgroundColor: "#87654321", borderRadius: "10px" }}>
        <textarea
          style={{ width: "100%", color: "blue", fontSize: "50px" }}
          placeholder="Title"
          maxlines={2}
          bindinput={(res: any) => {
            console.log(res.detail.value);
            setInputContent(res.detail.value);
          }}
        />
      </view>

      <view
        style={{
          width: "100%",
          padding: "10px",
          marginTop: "20px",
          backgroundColor: "#12345678",
          borderRadius: "10px",
        }}
      >
        {
          <textarea
            style={{ width: "100%", height: "300px", fontSize: "30px" }}
            placeholder="Content"
            bindinput={(res: any) => {
              console.log(res.detail.value);
              setInputContent(res.detail.value);
            }}
          />
        }
      </view>
    </view>
  );
};

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.0



### Custom Placeholder Style

`<textarea>` can customize its style using the `::placeholder` pseudo-element:

**This is an example below: textarea**

**Bundle:** `dist/base.lynx.bundle` | Web: `dist/base.web.bundle`

```tsx {13-21}
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root, useState } from "@lynx-js/react";
import "./index.scss";

const App = () => {
  const [inputContent, setInputContent] = useState("");

  return (
    <view style={{ linearOrientation: "vertical", width: "100%", height: "100%", padding: "20px" }}>
      <text style={{ fontSize: "15px" }}>Customized Placeholder And Caret Color</text>
      <view
        style={{
          width: "100%",
          padding: "10px",
          backgroundColor: "#87654321",
          borderRadius: "10px",
          marginTop: "20px",
        }}
      >
        <textarea
          style={{ width: "100%" }}
          placeholder=".textarea::placeholder {
                              color: oragne
                            }"
          class="textarea"
          bindinput={(res: any) => {
            console.log(res.detail.value);
            setInputContent(res.detail.value);
          }}
        />
      </view>
    </view>
  );
};

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.0



## Attributes

### `android-fullscreen-mode`

Android
3.4

```tsx
// @defaultValue: true
'android-fullscreen-mode'?: boolean;
```

Whether to enter the full-screen input mode when in landscape screen, in which the keyboard and input box will take up the entire screen

### `bounces`

iOS
3.4

```tsx
// @defaultValue: true
bounces?: boolean;
```

Bounce effect for iOS

### `confirm-type`

iOS
Harmony
3.4

```tsx
// @defaultValue: 'done'
'confirm-type'?: 'search' | 'send' | 'go' | 'done' | 'next';
```

The type of confirm button

### `disabled`

Android
iOS
Harmony
3.5

```tsx
// @defaultValue: false
disabled?: boolean;
```

Interaction enabled

### `enable-scroll-bar`

Android
iOS
3.6

```tsx
// @defaultValue: false
'enable-scroll-bar'?: boolean;
```

Whether to show scroll bar, on HarmonyOS, the scroll bar will always be shown

### `input-filter`

Android
iOS
Harmony
3.4

```tsx
// @defaultValue: undefined
'input-filter'?: string;
```

Filter the input content and process it in the form of regular expressions

### `ios-auto-correct`

iOS
3.4

```tsx
// @defaultValue: true
'ios-auto-correct'?: boolean;
```

Auto correct input content on iOS

### `ios-spell-check`

iOS
3.4

```tsx
// @defaultValue: true
'ios-spell-check'?: boolean;
```

Check spelling issue on iOS

### `line-spacing`

Android
iOS
3.4

```tsx
// @defaultValue: undefined
'line-spacing'?: number | any | any;
```

Line spacing

### `maxlength`

Android
iOS
Harmony
3.4

```tsx
// @defaultValue: 140
maxlength?: number;
```

Max input length

### `maxlines`

Android
iOS
Harmony
3.4

```tsx
// @defaultValue: undefined
maxlines?: number;
```

Max input lines

### `placeholder`

Android
iOS
Harmony
3.4

```tsx
placeholder?: string;
```

Placeholder

### `readonly`

Android
iOS
Harmony
3.4

```tsx
// @defaultValue: false
readonly?: boolean;
```

Readonly

### `show-soft-input-on-focus`

Android
iOS
3.4

```tsx
// @defaultValue: true
'show-soft-input-on-focus'?: boolean;
```

Show soft input keyboard while focused

### `type`

Android
iOS
Harmony
3.4

```tsx
// @defaultValue: "text"
type?: 'number' | 'text' | 'digit' | 'tel' | 'email';
```

Input content type

## Events

Frontend can bind corresponding event callbacks to listen for runtime behaviors of the element, as shown below.

### `bindblur`

Android
iOS
Harmony
3.4

```tsx
bindblur = (e: TextAreaBlurEvent) => {};
```

| Field | Type | Optional | Default | Platforms | Since | Description |
| --- | --- | --- | --- | --- | --- | --- |
| value | string | No | – | Android iOS Harmony 3.4 | 3.4 | Input content |

Blurred

### `bindconfirm`

Android
iOS
Harmony
3.4

```tsx
bindconfirm = (e: TextAreaConfirmEvent) => {};
```

| Field | Type | Optional | Default | Platforms | Since | Description |
| --- | --- | --- | --- | --- | --- | --- |
| value | string | No | – | Android iOS Harmony 3.4 | 3.4 | Input content |

Confirm button clicked, only work when confirm-type is defined

### `bindfocus`

Android
iOS
Harmony
3.4

```tsx
bindfocus = (e: TextAreaFocusEvent) => {};
```

| Field | Type | Optional | Default | Platforms | Since | Description |
| --- | --- | --- | --- | --- | --- | --- |
| value | string | No | – | Android iOS Harmony 3.4 | 3.4 | Input content |

Focused

### `bindinput`

Android
iOS
Harmony
3.4

```tsx
bindinput = (e: TextAreaInputEvent) => {};
```

| Field | Type | Optional | Default | Platforms | Since | Description |
| --- | --- | --- | --- | --- | --- | --- |
| isComposing | boolean | Yes | – | Android iOS Harmony 3.4 | 3.4 | Is composing or not |
| selectionEnd | number | No | – | Android iOS Harmony 3.4 | 3.4 | The end position of the selection |
| selectionStart | number | No | – | Android iOS Harmony 3.4 | 3.4 | The start position of the selection |
| value | string | No | – | Android iOS Harmony 3.4 | 3.4 | Input content |

Input content changed

### `bindselection`

Android
iOS
Harmony
3.4

```tsx
bindselection = (e: TextAreaSelectionChangeEvent) => {};
```

| Field | Type | Optional | Default | Platforms | Since | Description |
| --- | --- | --- | --- | --- | --- | --- |
| selectionEnd | number | No | – | Android iOS Harmony 3.4 | 3.4 | The end position of the selection |
| selectionStart | number | No | – | Android iOS Harmony 3.4 | 3.4 | The start position of the selection |

Input selection changed

## Methods

Frontend can invoke component methods via the [SelectorQuery](/next/api/lynx-api/nodes-ref/nodes-ref-invoke.md) API.

### `blur`

Android
iOS
Harmony
3.4

```ts

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'blur',
      success: function (res) {},
      fail: function (res) {},
    })
    .exec();

```

Release focus

### `focus`

Android
iOS
Harmony
3.4

```ts

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'focus',
      success: function (res) {},
      fail: function (res) {},
    })
    .exec();

```

Require focus

### `getValue`

Android
iOS
Harmony
3.4

```ts
interface GetValueResult {
  /**
   * Is composing or not, iOS only
   * @Android
   * @iOS
   * @Harmony
   * @Web
   * @since 3.4
   */
  isComposing: boolean;
  /**
   * End position of the cursor
   * @Android
   * @iOS
   * @Harmony
   * @Web
   * @since 3.4
   */
  selectionEnd: number;
  /**
   * Begin position of the cursor
   * @Android
   * @iOS
   * @Harmony
   * @Web
   * @since 3.4
   */
  selectionStart: number;
  /**
   * Input content
   * @Android
   * @iOS
   * @Harmony
   * @Web
   * @since 3.4
   */
  value: string;
}

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'getValue',
      success: function (res: GetValueResult) {},
      fail: function (res) {},
    })
    .exec();

```

Get input content

### `setSelectionRange`

Android
iOS
Harmony
3.4

```ts

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'setSelectionRange',
      params: {
        /**
         * End position of the selection
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @since 3.4
         */
        selectionEnd: 5,
        /**
         * Start position of the selection
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @since 3.4
         */
        selectionStart: 0,
      },
      success: function (res) {},
      fail: function (res) {},
    })
    .exec();

```

Set selection range

### `setValue`

Android
iOS
Harmony
3.4

```ts

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'setValue',
      params: {
        /**
         * Input content
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @since 3.4
         */
        value: 'hello',
      },
      success: function (res) {},
      fail: function (res) {},
    })
    .exec();

```

Set input content

## Compatibility

**Compatibility Table**

**Query:** `elements.textarea`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/elements/textarea.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| textarea | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| attributes | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Partial |
| attributes.placeholder | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| attributes.confirm-type | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| attributes.maxlength | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| attributes.readonly | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| attributes.show-soft-input-on-focus | Yes (3.4) | Yes (3.4) | Yes (3.4) | No | No | No |
| attributes.type | Yes (3.4) | Yes (3.4) | Yes (3.4) | No | No | No |
| attributes.input-filter | Yes (3.4) | Yes (3.4) | Yes (3.4) | No | No | Yes |
| attributes.maxlines | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | No |
| attributes.android-fullscreen-mode | Yes (3.4) | No | No | No | No | No |
| attributes.bounces | No | No | Yes (3.4) | No | No | No |
| attributes.default-value | Yes (4.0) | Yes (4.0) | Yes (3.4) | No | No | No |
| attributes.disabled | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| attributes.enable-scroll-bar | Yes (3.6) | No | Yes (3.5) | No | No | No |
| attributes.ios-auto-correct | No | No | Yes (3.4) | No | No | No |
| attributes.ios-spell-check | No | No | Yes (3.4) | No | No | Yes |
| attributes.line-spacing | Yes (3.4) | Yes (3.4) | Yes (3.4) | No | No | No |
| rests | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| events.bindblur | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (4.0) | Yes |
| events.bindconfirm | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (4.0) | Yes (4.0) | Yes |
| events.bindfocus | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (4.0) | Yes (3.4) | Yes |
| events.bindinput | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| events.bindselection | Yes (3.4) | Yes (3.4) | Yes (3.4) | No | No | Yes |
| methods.blur | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (4.0) | Yes (4.0) | Yes |
| methods.focus | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (4.0) | Yes (3.4) | Yes |
| methods.getValue | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| methods.setSelectionRange | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| methods.setValue | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes |
| methods.boundingClientRect | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (4.0) | Yes (4.0) | Yes |
| methods.requestAccessibilityFocus | Yes (3.4) | No | Yes (4.1) | No | No | No |
| methods.scrollIntoView | Yes (3.4) | Yes (3.4) | Yes (3.4) | Yes (4.0) | Yes (4.0) | Yes |
| methods.setFocus | No | No | No | Yes (4.0) | Yes (3.4) | No |
| methods.takeScreenshot | Yes (4.1) | Yes (4.1) | Yes (4.1) | Yes (4.0) | Yes (4.0) | No |

**`textarea`**

textarea

**`attributes`**

attributes

- **Web — Supported (version unknown):** Partial support; Web Lynx implements only part of this grouped feature.

**`attributes.placeholder`**

<code>placeholder</code>

**`attributes.confirm-type`**

<code>confirm-type</code>

**`attributes.maxlength`**

<code>maxlength</code>

**`attributes.readonly`**

<code>readonly</code>

**`attributes.show-soft-input-on-focus`**

<code>show-soft-input-on-focus</code>

**`attributes.type`**

<code>type</code>

- **Web — Not supported:** The Web textarea does not implement this attribute.

**`attributes.input-filter`**

<code>input-filter</code>

**`attributes.maxlines`**

<code>maxlines</code>

**`attributes.android-fullscreen-mode`**

<code>android-fullscreen-mode</code>

**`attributes.bounces`**

<code>bounces</code>

**`attributes.default-value`**

<code>default-value</code>

**`attributes.disabled`**

<code>disabled</code>

**`attributes.enable-scroll-bar`**

<code>enable-scroll-bar</code>

**`attributes.ios-auto-correct`**

<code>ios-auto-correct</code>

**`attributes.ios-spell-check`**

<code>ios-spell-check</code>

**`attributes.line-spacing`**

<code>line-spacing</code>

**`rests`**

All the rest

**`events.bindblur`**

<code>bindblur</code>

**`events.bindconfirm`**

<code>bindconfirm</code>

**`events.bindfocus`**

<code>bindfocus</code>

**`events.bindinput`**

<code>bindinput</code>

**`events.bindselection`**

<code>bindselection</code>

**`methods.blur`**

<code>blur</code>

**`methods.focus`**

<code>focus</code>

**`methods.getValue`**

<code>getValue</code>

**`methods.setSelectionRange`**

<code>setSelectionRange</code>

**`methods.setValue`**

<code>setValue</code>

**`methods.boundingClientRect`**

<code>boundingClientRect</code>

**`methods.requestAccessibilityFocus`**

<code>requestAccessibilityFocus</code>

**`methods.scrollIntoView`**

<code>scrollIntoView</code>

**`methods.setFocus`**

<code>setFocus</code>

**`methods.takeScreenshot`**

<code>takeScreenshot</code>

