Textarea

stable 1.6 kB
<hk-textarea>

A textarea that grows with its content up to a ceiling, then scrolls — so a one-line note does not reserve six lines of empty space.

#text#multiline

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
valuestring''Model value. Two-way bindable.
rowsnumber2Starting height in rows.
maxRowsnumber10Height ceiling. Past it the field scrolls instead of growing.
autoGrowbooleantrueResizes to fit the content on every input.
maxlengthnumber | nullnullHard character limit.
counterbooleanfalseShows characters remaining. Needs maxlength.

Outputs

  • valueChangeEventEmitter<string>

    Emits on every keystroke.

Keyboard

  • Enter Inserts a newline — the field never submits the form

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-textarea-min4remFloor height, so an empty field still has a target.
--hk-textarea-max16remCeiling before the field scrolls.

Accessibility

  • Resizing happens after the value lands, so the first paint is already the right height and nothing jumps.
  • The counter is aria-live="polite" and only announces near the limit, not on every keystroke.

More in Forms