1e41f4b71Sopenharmony_ci# textarea 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci> **NOTE** 4e41f4b71Sopenharmony_ci> 5e41f4b71Sopenharmony_ci> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciThe **\<textarea>** component provides a text box to receive multi-line text input. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## Required Permissions 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciNone 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## Child Components 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ciNot supported 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci## Attributes 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ciIn addition to the [universal attributes](js-components-common-attributes.md), the following attributes are supported. 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci| Name | Type | Default Value| Mandatory| Description | 25e41f4b71Sopenharmony_ci| -------------------------------- | ----------------------- | ------ | ---- | ------------------------------------------------------------ | 26e41f4b71Sopenharmony_ci| placeholder | string | - | No | Content of the hint text. | 27e41f4b71Sopenharmony_ci| maxlength | number | - | No | Maximum number of characters that can be entered in the multi-line text box. | 28e41f4b71Sopenharmony_ci| headericon | string | - | No | Icon displayed before text input. This icon does not support click events. The supported icon formats are JPG, PNG, and SVG.| 29e41f4b71Sopenharmony_ci| extend | boolean | false | No | Whether a text box can be extended. If the value of this attribute is set to **true**, the height of the text box can adapt to the text.| 30e41f4b71Sopenharmony_ci| value<sup>5+</sup> | string | - | No | Content in a multi-line text box. | 31e41f4b71Sopenharmony_ci| showcounter<sup>5+</sup> | boolean | false | No | Whether to display the character counter for the text box. This attribute takes effect only when **maxlength** is set. | 32e41f4b71Sopenharmony_ci| menuoptions<sup>5+</sup> | Array<MenuOption> | - | No | Menu options displayed after users click the **More** button. | 33e41f4b71Sopenharmony_ci| autofocus<sup>6+</sup> | boolean | false | No | Whether to automatically obtain focus. | 34e41f4b71Sopenharmony_ci| selectedstart<sup>6+</sup> | number | -1 | No | Start position for text selection. | 35e41f4b71Sopenharmony_ci| selectedend<sup>6+</sup> | number | -1 | No | End position for text selection. | 36e41f4b71Sopenharmony_ci| softkeyboardenabled<sup>6+</sup> | boolean | true | No | Whether to display the soft keyboard during editing. | 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci**Table 1** MenuOption<sup>5+</sup> 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci| Name | Type | Description | 41e41f4b71Sopenharmony_ci| ------- | ------ | ----------- | 42e41f4b71Sopenharmony_ci| icon | string | Path of the icon for a menu option.| 43e41f4b71Sopenharmony_ci| content | string | Text content of a menu option.| 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci## Styles 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ciIn addition to the [universal styles](js-components-common-styles.md), the following styles are supported. 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci| Name | Type | Default Value | Mandatory | Description | 51e41f4b71Sopenharmony_ci| ------------------------ | -------------------------- | ---------- | ---- | ---------------------------------------- | 52e41f4b71Sopenharmony_ci| color | <color> | \#e6000000 | No | Text color of the multi-line text box. | 53e41f4b71Sopenharmony_ci| font-size | <length> | 16px | No | Font size of the multi-line text box. | 54e41f4b71Sopenharmony_ci| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings.<br>If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart.| 55e41f4b71Sopenharmony_ci| placeholder-color | <color> | \#99000000 | No | Color of the hint text in the multi-line text box. This attribute is available when the component type is set to one of the following: text\|email\|date\|time\|number\|password.| 56e41f4b71Sopenharmony_ci| font-weight | number \| string | normal | No | Font weight. For details, see **font-weight** of the [**\<text>**](js-components-basic-text.md#styles) component.| 57e41f4b71Sopenharmony_ci| font-family | string | sans-serif | No | Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the specified [custom font](js-components-common-customizing-font.md) is used for the text.| 58e41f4b71Sopenharmony_ci| caret-color<sup>6+</sup> | <color> | - | No | Color of the caret. | 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci## Events 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ciIn addition to the [universal events](js-components-common-events.md), the following events are supported. 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci| Name | Parameter | Description | 66e41f4b71Sopenharmony_ci| ------------------------- | ---------------------------------------- | ---------------------------------------- | 67e41f4b71Sopenharmony_ci| change | { text: newText, lines: textLines, height: textHeight } | Triggered when the input content changes. The input content, number of rows, and row height are obtained through the parameters.<br>Since API version 5, if you change the value attribute directly, this event will not be triggered.| 68e41f4b71Sopenharmony_ci| translate<sup>5+</sup> | { value: selectedText } | Triggered when users click the translate button in the menu displayed after they select a text segment. The selected text content is returned.| 69e41f4b71Sopenharmony_ci| share<sup>5+</sup> | { value: selectedText } | Triggered when users click the share button in the menu displayed after they select a text segment. The selected text content is returned.| 70e41f4b71Sopenharmony_ci| search<sup>5+</sup> | { value: selectedText } | Triggered when users click the search button in the menu displayed after they select a text segment. The selected text content is returned.| 71e41f4b71Sopenharmony_ci| optionselect<sup>5+</sup> | { index:optionIndex, value: selectedText } | Triggered when users click a menu option in the menu displayed after they select a text segment. This event is valid only when the **menuoptions** attribute is set. The option index and selected text content are returned.| 72e41f4b71Sopenharmony_ci| selectchange<sup>6+</sup> | { start: number, end: number }| Triggered when the text selection changes. | 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci## Methods 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ciThe [universal methods](js-components-common-methods.md) are supported. 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci## Example 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci```html 83e41f4b71Sopenharmony_ci<!-- xxx.hml --> 84e41f4b71Sopenharmony_ci<textarea id="textarea" class="textarea" extend="true" maxlength="20" 85e41f4b71Sopenharmony_ci headericon="/common/navigation_menu1_icon.svg" placeholder="Please input text" 86e41f4b71Sopenharmony_ci onchange="change"> 87e41f4b71Sopenharmony_ci</textarea> 88e41f4b71Sopenharmony_ci``` 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci```css 91e41f4b71Sopenharmony_ci/* xxx.css */ 92e41f4b71Sopenharmony_ci.textarea { 93e41f4b71Sopenharmony_ci placeholder-color: gray; 94e41f4b71Sopenharmony_ci} 95e41f4b71Sopenharmony_ci``` 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci```js 98e41f4b71Sopenharmony_ci// xxx.js 99e41f4b71Sopenharmony_ciimport promptAction from '@ohos.promptAction'; 100e41f4b71Sopenharmony_ciexport default { 101e41f4b71Sopenharmony_cichange(e){ 102e41f4b71Sopenharmony_ci promptAction.showToast({ 103e41f4b71Sopenharmony_ci message: 'value: ' + e.text + ', lines: ' + e.lines + ', height: ' + e.height, 104e41f4b71Sopenharmony_ci duration: 3000, 105e41f4b71Sopenharmony_ci }); 106e41f4b71Sopenharmony_ci} 107e41f4b71Sopenharmony_ci} 108e41f4b71Sopenharmony_ci``` 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci 111