Textarea
HkTextarea is the standalone multi-line editor: a native <textarea> in a thin wrapper, with a row count, optional auto-grow, a native maxLength cap and a count / max line under it. It carries no caption, no affixes and no message line — that chrome belongs to the textarea branch of HkInput.
- For a caption, an affix or an error line, use HkInput with type="textarea".
- For a single-line entry, use HkInput.
- For long prose that should count characters against a public limit, this is the component: showCount plus maxLength.
Import
;
use *; // Textarea
use *; // rsx!, VNode
The Rust form is a plain function, Textarea(TextareaProps { … }). Its rows default is 4 — HkInput's textarea branch defaults to 3 — so the standalone editor starts one row taller than the boxed variant.
Rows and auto-grow
rows sets the visible height; autoGrow lets the editor grow with its content. In Vue the height is measured after every input and on width changes (scrollHeight through a ResizeObserver); the Rust mirror can only switch the sheet's auto-grow face on (resize: none; overflow: hidden), so a host that wants a growing field pins the height itself.
Counter and limit
With maxLength and showCount the wrapper renders count / max under the editor, and the count turns red once the value passes the limit. The count is the value's String.length in both forms — UTF-16 code units, so an astral character such as an emoji counts 2.
Disabled
A disabled editor is dimmed and cannot be focused or edited, but its text stays readable and selectable; the wrapper carries the hk-textarea-disabled marker the stylesheet keys on.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| modelValue | String | "" | — |
| placeholder | String | undefined | — |
| disabled | Boolean | false | — |
| rows | Number | 4 | — |
| autoGrow | Boolean | false | — |
| maxLength | Number | undefined | — |
| showCount | Boolean | false | — |
Emits
| Event | Payload |
|---|---|
| update:modelValue | string |
Rust
Props — Textarea
| Prop | Type | Default | Description |
|---|---|---|---|
| model_value | String | "" | Vue: modelValue, default "". |
| placeholder | Option<String> | None | Native placeholder (Vue default undefined). |
| disabled | bool | false | — |
| rows | u32 | 4 | Visible row count (Vue: rows, default 4). |
| auto_grow | bool | false | Auto-grow opt-in (Vue: autoGrow); see the header delta — the mirror can only carry the sheet's autogrow face, not the measured height. |
| max_length | Option<u32> | None | Native maxlength cap (Vue: maxLength, default undefined). |
| show_count | bool | false | Render the count / max line (Vue: showCount). |
| class | String | "" | — |
| oninput | Option<EventHandler<String>> | None | Fires with the field's new text (Vue: update:modelValue). |
| onchange | Option<EventHandler<ChangeEvent>> | None | Vue: the change emit (a listener the attrs spread brings along). |
| attrs | Vec<(String, String)> | [] | Attributes set on the field element by name, after the component's own — title, data-*, aria-*, test hooks (Vue: the attrs spread on the element). |
| bare | bool | false | Render the field element alone: no wrapper, no counter line, class on the element and none of the sheet's own classes — the host draws the chrome and keeps the event wiring. |
Accessibility
- The editor is a native <textarea>, so it takes focus with Tab and accepts every platform text shortcut. Its value rides the element's value attribute in both forms, so assistive technology reads what the host handed in.
- This component renders no caption, so give it a name from the host: a <label> next to it (with for and a matching id), or ariaLabel on the element — pass label through HkInput when the caption belongs in the box chrome.
- The counter is plain text in a sibling div, not a live region: nothing is announced while typing, which keeps a long paste from interrupting. Announce the limit yourself if a hard cap matters.
- The native scrollbar is deliberately kept — a live caret, IME composition and drag-selection need the browser's own scroller.
Related components
- HkInput — the boxed field, with type="textarea" for a captioned multi-line editor.
- HkSearchInput — the single-line search field.
- HkOtpInput — the other field that publishes a completion edge.