Skip to content

Textarea

WxTextarea is the multi-line sibling of WxInput: same states, same form integration, plus autosizing and a character counter.

Fixed rows, counter
50/200
Autosize between 2 and 6 rows
States

Usage

vue
<script setup lang="ts">
import { ref } from 'vue'

const summary = ref('')
</script>

<template>
  <wx-textarea v-model="summary" :rows="4" :maxlength="200" show-count />
</template>

Autosize

autosize grows the field with its content. Bound it to keep a long text from taking over the page — past maxRows the field scrolls instead of growing:

vue
<template>
  <wx-textarea v-model="notes" :autosize="{ minRows: 2, maxRows: 6 }" />
</template>

While autosizing, manual resizing is switched off — the two fight each other otherwise.

Props

PropTypeDefaultDescription
modelValuestring''v-model value
rowsnumber3Visible rows when autosize is off
autosizeboolean | { minRows?: number; maxRows?: number }falseGrows with the content
maxlengthnumberNative maxlength
showCountbooleanfalseRenders current / max (needs maxlength)
resize'none' | 'vertical' | 'both''vertical'Manual resize handle
size'sm' | 'md' | 'lg''md'Font size
status'default' | 'success' | 'warning' | 'error''default'Validation state
placeholderstringPlaceholder text
disabledbooleanfalseDisables the field
readonlybooleanfalseRead-only field
idstringgeneratedOverrides the id the label points at; WxFormItem supplies one
ariaLabelstringLabel when there is no visible one

Events: update:modelValue (string), input (string), change (string), focus, blur.

Exposed: focus(), blur(), select(), and textarea — a ref to the native element.

Unknown attributes fall through to the <textarea>, not the wrapper. class and style are the two that stay on the wrapper — see Input for why.

Accessibility

Inside a WxFormItem the id, error state and aria-describedby are wired automatically. Standalone, give it an ariaLabel.

Released under the MIT License.