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.

Placeholders ​

The same as Input: tokens turns on the list on [, the button in the top corner and the chips. The mirror wraps where the textarea wraps and scrolls with it, and the list opens under the line being typed rather than under the field.

Props ​

PropTypeDefaultDescription
modelValuestring''v-model value
rowsnumber3Visible rows when autosize is off
autosizeboolean | { minRows?: number; maxRows?: number }falseGrows with the content
maxlengthnumber—Native 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
placeholderstring—Placeholder text
disabledbooleanfalseDisables the field
readonlybooleanfalseRead-only field
idstringgeneratedOverrides the id the label points at; WxFormItem supplies one
ariaLabelstring—Label when there is no visible one
tokensTokenOption[]—Placeholders to suggest on [, list from the button and draw as chips
tokensTitlestring'Placeholders'Heading of the list the button opens
tokensLabelstring'Insert a placeholder'Name and tooltip of the button

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.