Textarea
VTextarea is a multiline field with optional label, help text, icons and actions. Use autoGrow to fit its height to the content.
Usage
Examples
Label and hint
label names the field. hint adds help text linked through aria-describedby.
Sizes
size adjusts padding, text and icons. rows sets the line count.
Icons
iconStart and iconEnd align with the first line. Use #start and #end for custom content.
Clickable icons
Attach @click:icon-start or @click:icon-end to make an icon a button. Provide its accessible name with iconStartLabel or iconEndLabel.
Clear button
clearable adds a button that empties the field, emits clear and restores focus.
Character counter
counter displays the character count below the field. With maxlength, softLimit allows typing past the limit and reports a native validation error.
Automatic height
autoGrow adjusts the height to the content, with rows as the minimum. Without it, the field scrolls and can be resized vertically.
States
disabled blocks interaction. readonly allows focus and copying. invalid marks an error, and error also shows its message in place of the hint. loading shows a spinner while leaving the field editable.
API
Props
| Prop | Type | Default |
|---|---|---|
size | TextareaSize'sm' | 'md' | 'lg' | 'md' |
Adjusts padding, text and icons. Use rows to set the line count. | ||
rows | number | 5 |
Visible line count, rounded to an integer of at least 1. With autoGrow, sets the minimum height. | ||
autoGrow | boolean | false |
Fits the height to the content using CSS field-sizing. Disables manual resizing. Without browser support, the field keeps its fixed height and scrolls. | ||
invalid | boolean | false |
Sets aria-invalid and the error style. Does not block form submission by itself. | ||
disabled | boolean | false |
| Disables the field, removing it from Tab navigation and form submission. | ||
readonly | boolean | false |
Prevents editing while allowing focus and copying. Hides the clear button unless clearVisible overrides it. | ||
label | string | none |
Visible label linked to the textarea. When omitted, provide aria-label or aria-labelledby. | ||
hint | string | none |
Help text below the field, linked through aria-describedby. | ||
error | string | none |
Error message shown in place of the hint. Sets aria-invalid, is linked through aria-describedby and is announced when it appears. | ||
required | boolean | false |
Adds an asterisk after the label and passes required to the field. | ||
hideLabel | boolean | false |
| Hides the label visually while keeping it as the accessible name. | ||
labelPosition | FieldLabelPosition'top' | 'start' | 'top' |
| Places the label above the field or beside it. | ||
iconStart | IconSource | none |
Start icon. Becomes a button with @click:icon-start; then requires iconStartLabel. | ||
iconEnd | IconSource | none |
End icon. Becomes a button with @click:icon-end; then requires iconEndLabel. Replaced by #end or the loading spinner. | ||
iconStartLabel | string | none |
| Accessible name of the start icon button. | ||
iconEndLabel | string | none |
| Accessible name of the end icon button. | ||
loading | boolean | false |
Replaces the end icon or #end content with a spinner. Does not disable the field. | ||
loadingText | string | none |
| Accessible spinner text. Defaults to the library dictionary. | ||
clearable | boolean | false |
Adds a clear button when the field is non-empty and editable, unless clearVisible overrides visibility. Hidden when disabled. | ||
clearVisible | boolean | none |
Overrides the content and read-only checks for clear-button visibility. Requires clearable and an enabled field. | ||
clearLabel | string | none |
| Accessible name of the clear button. Defaults to the library dictionary. | ||
maxlength | number | none |
Native character limit. Not applied as a native attribute with softLimit. | ||
softLimit | boolean | false |
Allows exceeding maxlength and sets a native validation error until the value is within the limit. | ||
counter | boolean | false |
Character count below the field: 12/80 with a limit, or 12 without one. | ||
v-model | string | '' |
| Field text. Defaults to an empty string. | ||
Events
| Event | Type |
|---|---|
click:icon-start | [event: MouseEvent] |
Emitted when the start icon button is activated. Receives a MouseEvent. | |
click:icon-end | [event: MouseEvent] |
Emitted when the end icon button is activated. Receives a MouseEvent. | |
clear | [] |
| Emitted after the clear button resets the value to an empty string. | |
Slots
| Slot | Type |
|---|---|
start | {} |
Content after iconStart. Does not replace the icon. | |
end | {} |
Content replacing iconEnd. Hidden while loading. | |
value-end | {} |
| Content after the textarea, before the clear button and end icon. | |
Types
Types used in the API tables. Import exported types from vectis-ui.
export interface BuiltinIcon {
name: string
paths: readonly [string] | readonly [string, string]
}export type IconRender =
| { path: string; viewBox?: string }
| { component: Component; props?: Record<string, unknown> }
| { src: string }
| { text: string; class?: string }
| { class: string }export type IconSource = string | BuiltinIcon | IconRender