Textarea
A field for text of several lines. Same label, helper and error as an Input.
Showcase
<LnxTextarea v-model="..." <-- Pass a reactive variable here to bind its value @update:modelValue="..." <-- Two way binding of the component > Comments </LnxTextarea>
customValidity
stringThe error message of the textarea. It is the default value for the `error` slot Default value: undefinedautoGrow
booleanGrows with the text, from `rows` up to `maxRows`. Where the browser has no `field-sizing`, it keeps its size Default value: falseshowCount
booleanWith `maxlength`, shows how many characters are used, like 120/500 Default value: falseWhen to use
- For free text that may take more than one line: comments, descriptions, notes.
- For a short answer, use an Input.
Examples
Grows with the text
auto-grow starts at rows and grows as the user writes, up to max-rows; then it scrolls. It uses the CSS field-sizing: browsers without it keep the size of rows.
vue
<LnxTextarea v-model="notes" auto-grow rows="2" :max-rows="6" placeholder="Write a few lines…">
Notes
</LnxTextarea>1
2
3
2
3
Count
With maxlength and show-count, the characters used show at the right of the helper.
It's shown in the list of minutes
0/140vue
<LnxTextarea v-model="summary" maxlength="140" show-count>
Summary
<template #helper>It's shown in the list of minutes</template>
</LnxTextarea>1
2
3
4
2
3
4
Error
Set has-error and the message in custom-validity, also set as the native validity of the textarea.
Tell us why you reject it
vue
<LnxTextarea v-model="reason" has-error custom-validity="Tell us why you reject it">
Reason
</LnxTextarea>1
2
3
2
3
API
Props
| Prop | Type | Description |
|---|---|---|
v-model | string | Binds the text to the reactive variable used as prop |
is-loading | boolean | When loading, it is readonly and disabled Default: false |
has-error | boolean | Indicates if it should show the error slot Default: false |
custom-validity | string | The error message of the textarea. It is the default value for the error slot |
auto-grow | boolean | Grows with the text, from rows up to maxRows. Where the browser has no field-sizing, it keeps its sizeDefault: false |
max-rows | number | With autoGrow, the rows it grows up to before it scrolls |
show-count | boolean | With maxlength, shows how many characters are used, like 120/500Default: false |
Events
| Event | Payload | Description |
|---|---|---|
update:modelValue | string | Two way binding of the component |
Slots
| Slot | Scope | Description |
|---|---|---|
default | — | The label of the textarea |
helper | — | Message below the textarea to add extra context |
error | — | Message shown when the textarea has an error |
Accessibility
- The label names the textarea. The limit of
maxlengthis native, so the count is only a visual aid.