Textarea (文本域)

多行输入(v-model),支持自动增高、调整大小与字数统计。

基础用法

A short description about yourself.

Basic.vue

自动增高与字数

0/200
AutoGrow.vue

状态与尺寸

Please enter a message.

States.vue

颜色

Colors.vue

属性

属性类型默认值说明
autofocusbooleanfalseFocus the field on mount. Focus is moved with `preventScroll`, so it never jogs the page: an autofocused input inside a popover is at the document origin until Floating UI has positioned it, and letting the browser scroll to it there threw the page to the top.
autoGrowbooleanfalseGrow the field with its content up to `maxHeight`, instead of scrolling at a fixed `rows`.
colorKunUIColor"default"Focus-ring accent (the resting border/text stay neutral). Default 'default'.
darkBorderbooleantrueLegacy dark-mode border toggle. 已废弃:No-op since 0.18.0. Every neutral border now resolves to the unified `--color-kun-border` token (the `border-kun` utility), which already flips light↔dark — so the old light-translucent / dark-solid split this prop toggled is gone. Safe to remove from call sites.
descriptionstring""Helper text below the field (hidden when `error` is set). Canonical name.
disabledbooleanfalseBlocks input and dims the field.
errorstring""Error message below the field. Setting it also paints the invalid state and hides `description`.
hintstring""Helper text below the field. 已废弃:Use `description` (unified across all KunUI form controls).
labelstring""Visible label above the field, tied to it by `id` so a click focuses the textarea.
maxHeightstring""Ceiling for `autoGrow`, any CSS length (e.g. `"12rem"`). The field scrolls internally past it instead of growing forever.
maxlengthnumber—Native maximum length; unset, the field takes any length. Also the denominator of `showCharCount`.
minlengthnumber1Native minimum length, enforced by form validation.
modelValuestring""The textarea's text, two-way bound with `v-model`.
namestring""Native form field name, for an uncontrolled `<form>` submit.
placeholderstring""Placeholder text. It is not a label — pair it with `label` or `ariaLabel`.
readonlybooleanfalseValue is selectable and copyable but not editable — unlike `disabled`, it stays focusable and is still submitted.
requiredbooleanfalseMarks the field required for native validation and assistive tech.
resize"none" | "horizontal" | "vertical" | "both""none"Which way the user may drag the native resize handle.
roundedKunUIRounded—Corner radius. Unset follows the app-wide config (default `md`).
rowsnumber4Initial visible rows — the field's height before `autoGrow` takes over.
showCharCountbooleanfalseShow a live character counter in the field's corner: `used/maxlength` when `maxlength` is set, the bare count otherwise.
sizeKunUISize"md"Height, padding and font size, on the shared form-control scale.

事件

事件回调参数
blurevent: FocusEvent
focusevent: FocusEvent
inputevent: Event
update:modelValuevalue: string