TextareaField
Form field component for multi-line text input with validation support.
Component
Help text example
11 / 500
Props
| Props | Required | Default | Type |
|---|---|---|---|
id | true | — | string |
label | — | — | string |
placeholder | — | 'Placeholder' | string |
helpText | — | — | string |
helpTextPosition | — | Position.BOTTOM | Position |
modelValue | — | '' | string |
validator | — | — | function |
error | — | '' | string |
maxLength | true | — | number |
hasCharCounter | — | true | boolean |
readonly | — | false | boolean |
autocomplete | — | 'off' | string |
autofocus | — | false | boolean |
wrap | — | 'soft' | 'soft' | 'hard' |
spellcheck | — | false | boolean |
autoResize | — | false | boolean |
blurContent | — | false | boolean |
revealBlurOnFocus | — | true | boolean |
disabled | — | false | boolean |
required | — | false | boolean |
showOptionalLabel | — | true | boolean |
optionalLabel | — | — | string |
minHeightClass | — | 'min-h-[150px]' | string |
maxHeightClass | — | 'max-h-[300px]' | string |
textareaClass | — | — | string |
transparent | — | false | boolean |
Usage
id
Sets the id of the field.
<template>
<TextareaField id="field-id" />
</template>
label
Sets the label of the field.
<template>
<TextareaField label="Label text" />
</template>
placeholder
Sets the placeholder text of the input field.
<template>
<TextareaField placeholder="Placeholder" />
</template>
helpText
Sets the help text displayed below the input field.
<template>
<TextareaField helpText="Help text example" />
</template>
helpTextPosition
Sets the position of the help text relative to the field. It uses the Position enum.
<template>
<TextareaField helpTextPosition="top" helpText="Appears above the field" />
</template>
Options
| Value | Description |
|---|---|
TOP | top |
BOTTOM | bottom |
modelValue
Sets the value of the textarea.
<template>
<TextareaField v-model="textValue" />
</template>
<script setup lang="ts">
const textValue = ref('Sample text');
</script>
validator
Sets the validator function for the field, which controls its internal validation state.
It uses the validateField utility to perform required field validation.
<template>
<TextareaField :validator="validateField" />
</template>
error (v-model:error)
Sets the error message of the field. This prop is bindable via v-model:error, allowing two-way syncing of the validation state.
<template>
<TextareaField v-model:error="errorMessage" />
</template>
maxLength
Sets the maximum length of the textarea.
<template>
<TextareaField :maxLength="500" />
</template>
hasCharCounter
Enables or disables the character counter display.
<template>
<TextareaField hasCharCounter />
</template>
readonly
Sets the textarea to read-only mode.
<template>
<TextareaField readonly />
</template>
autocomplete
Sets the autocomplete attribute of the textarea.
<template>
<TextareaField autocomplete="off" />
</template>
autofocus
Sets the autofocus state of the field.
<template>
<TextareaField autofocus />
</template>
wrap
Sets the wrap attribute of the textarea.
<template>
<TextareaField wrap="soft" />
</template>
spellcheck
Sets the spellcheck attribute of the textarea.
<template>
<TextareaField spellcheck />
</template>
autoResize
Enables or disables the auto-resize feature of the textarea. It does not refer to the native resize property of the textarea, but to automatically adjusting the height based on the content.
<template>
<TextareaField autoResize />
</template>
blurContent
Enables or disables the blur effect on the content of the textarea.
<template>
<TextareaField blurContent />
</template>
Security note
Blurring the content does not protect sensitive information. Users can still copy or view the content in other ways.
To prevent sensitive information from being exposed, consider using other security measures such as encryption or secure storage.
Additionally, you can handle the value of v-model dynamically:
<template>
<TextareaField
id="protected-field"
v-model="protectedValue"
v-model:blurContent="isBlurred"
/>
</template>
<script setup lang="ts">
const protectedValue = ref('')
const isBlurred = ref(true)
// Example reveal logic
const revealValue = async () => {
const decrypted = await fetchSecret()
protectedValue.value = decrypted
isBlurred.value = false
}
</script>
revealBlurOnFocus
Controls whether the blur effect is revealed when the textarea is focused.
<template>
<TextareaField revealBlurOnFocus />
</template>
disabled
Sets the disabled state of the field.
<template>
<TextareaField disabled />
</template>
required
Sets the required state of the field.
<template>
<TextareaField required />
</template>
showOptionalLabel
When the field is not required, shows an "(optional)" hint next to the label. Set to false to hide it. The hint text defaults to a global setting that can be overridden project-wide, and can also be overridden per field with the optionalLabel prop.
<template>
<TextareaField label="Notes" :showOptionalLabel="false" />
</template>
optionalLabel
Overrides the "(optional)" hint text for this specific field, taking priority over the global default.
<template>
<TextareaField label="Notes" optionalLabel="(not required)" />
</template>
minHeightClass
Sets the minimum height CSS class for the textarea.
<template>
<TextareaField minHeightClass="min-h-[150px]" />
</template>
maxHeightClass
Sets the maximum height CSS class for the textarea.
Max height only applies when autoResize is enabled.
<template>
<TextareaField maxHeightClass="max-h-[300px]" />
</template>
textareaClass
Sets the custom CSS class for the textarea.
<template>
<TextareaField textareaClass="border-border-success" />
</template>
transparent
When true, removes the default bg-background-container-surface background from the textarea container, making it transparent.
<template>
<TextareaField transparent />
</template>