Textarea
Multi-line text input. The height grows with the number of rows and the content, and it supports a character counter and a character limit.
Spec source:
lh-ui-core/specs/textarea.json· Golden cases:lh-ui-core/cases/textarea.json(6 cases, translated into hypium tests)
Basic usage
rows decides the initial number of visible rows, and the minimum height comes from the textarea.minHeight token.
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
LhTextarea({
value: this.remark,
placeholder: 'Please enter remarks',
rows: 3,
onValueChange: (value: string) => { this.remark = value },
})Character counter
When showCount is true, a character counter is shown in the bottom-right corner: with maxlength set, it displays current/limit; without it, only the current length is shown.
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
API
Props
| Prop | Description | Type | Default |
|---|---|---|---|
value | Current text value (controlled) | string | '' |
placeholder | Placeholder hint text | string | '' |
rows | Initial number of visible rows; the height grows with rows and content | number | 3 |
disabled | Whether disabled; ignores input and does not fire onValueChange when disabled | boolean | false |
readonly | Whether read-only; focusable but accepts no input when read-only | boolean | false |
showCount | Whether to show the character counter in the bottom-right corner | boolean | false |
maxlength | Maximum character count; excess input is truncated; the denominator when showCount is on | number? | undefined |
onValueChange | Fired when the text changes; not fired when disabled / readonly | (value: string) => void | Empty function |
onFocus | Fired when focus is gained | () => void | Empty function |
onBlur | Fired when focus is lost | () => void | Empty function |
Token reference
| Token | Purpose |
|---|---|
textarea.minHeight | Minimum height when empty (72vp, roughly three rows) |
textarea.paddingHorizontal / textarea.paddingVertical | Paddings (12 / 12vp) |
textarea.fontSize | Input font size (14) |
textarea.countFontSize | Counter font size (12) |
textarea.borderRadius / textarea.borderWidth | Corner radius and border width |
textarea.focusRingWidth | Focus ring width |
typography.lineHeight.primary | Line height (1.8) |
color.text.primary / color.text.placeholder | Input text / placeholder text color |
color.background.default / color.background.disabled | Background / disabled background color |
color.border.base / color.focus | Border color / focus color |
Golden case reference
How the 6 assertions in cases/textarea.json map onto hypium tests (entry/src/test/Textarea.test.ets):
| case id | Assertion | Local test |
|---|---|---|
input-emits-onvaluechange | Typing fires onValueChange | disabled_is_not_interactive (inverse gate assertion) |
disabled-blocks-input | Disabled state ignores input | disabled_is_not_interactive |
showcount-renders-count | The counter renders current/limit | showcount_renders_count_with_maxlength |
showcount-without-maxlength-renders-length-only | Without a limit, only the length is shown | showcount_renders_length_only_without_maxlength |
focus-uses-focus-token | Focused state uses the focus token | focus_uses_focus_token |
maxlength-truncates-input | Input beyond the limit is truncated | maxlength_truncates_input |
Plus dark-mode specifics: dark_colors_come_from_dark_tokens / dimensions_are_identical_in_dark_mode. To run: in DevEco Studio, right-click entry/src/test → Run Tests.

