Textarea

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

tsx
1
import { HkTextarea } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // Textarea
use hikari_components::prelude::*; // 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.

0 / 280
61 / 30

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

NameTypeDefaultRequired
modelValueString""—
placeholderStringundefined—
disabledBooleanfalse—
rowsNumber4—
autoGrowBooleanfalse—
maxLengthNumberundefined—
showCountBooleanfalse—

Emits

EventPayload
update:modelValuestring

Rust

Props — Textarea

PropTypeDefaultDescription
model_valueString""Vue: modelValue, default "".
placeholderOption<String>NoneNative placeholder (Vue default undefined).
disabledboolfalse—
rowsu324Visible row count (Vue: rows, default 4).
auto_growboolfalseAuto-grow opt-in (Vue: autoGrow); see the header delta — the mirror can only carry the sheet's autogrow face, not the measured height.
max_lengthOption<u32>NoneNative maxlength cap (Vue: maxLength, default undefined).
show_countboolfalseRender the count / max line (Vue: showCount).
classString""—
oninputOption<EventHandler<String>>NoneFires with the field's new text (Vue: update:modelValue).
onchangeOption<EventHandler<ChangeEvent>>NoneVue: the change emit (a listener the attrs spread brings along).
attrsVec<(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).
bareboolfalseRender 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.