Text Area
Alignment target:@astryxdesign/core v0.7.1 · TextArea
Usage #
Use TextArea to enter multi-line plain text.
<script setup lang="ts">
import { TextArea } from '@astryx-vue/core/TextArea'
import { shallowRef } from 'vue'
const bio = shallowRef('')
</script>
<template>
<TextArea v-model="bio" label="Bio" :rows="4" />
</template>Import the theme once in the application entry:
import '@astryx-vue/themes/neutral.css'Anatomy
| Element | Description |
|---|---|
| Label | Text identifying the multi-line field. |
| Description | Helper text between the label and the input. |
| Input container | Painted boundary containing the text area and its overlays. |
| Text area | Multi-line control that displays and edits the value. |
| Placeholder | Hint text shown inside the empty text area. |
| Start icon | Astryx Icon rendered at the start when startIcon is a semantic name or icon component. |
| Custom start content | Caller-provided slot content rendered at the start instead of an Astryx Icon. |
| Spinner | Loading indicator shown at the end of the input container. |
| Status icon | Error, warning, or success icon shown inside the input. |
| Character counter | Current and maximum character counts shown inside the input container. |
| Field status message | Attached or detached error, warning, or success message associated with the field. |
| Tooltip status message | Tooltip surface presenting the status message for the tooltip variant. |
Best practices #
| Guidance | Practices |
|---|---|
| Do | Provide a visible label so users know what to enter. If the label must be hidden, set isLabelHidden with a descriptive label for screen readers. |
| Do | Set maxLength with a character counter when there is a defined limit; it helps users stay within bounds before they submit. |
| Do | Use the status prop to surface validation feedback inline: show success when input is valid, warning for soft limits, and error for hard failures. |
| Do | Add a description or placeholder to clarify expected content, like "Describe the issue in detail," but never rely on placeholder alone as the only label. |
| Don't | Avoid using TextArea for short, single-line values like names or emails; use TextInput instead. |
| Don't | Don't rely solely on placeholder text to communicate the purpose of the field; placeholders disappear on focus and are not accessible labels. |
| Don't | Don't show a status message without also setting the status type; the colored border and icon are what draw the user's attention to the message. |
| Don't | Don't wrap a disabled TextArea in Tooltip to explain why it's disabled; disabled controls swallow the hover events the wrapper needs. Use the disabledMessage prop instead. |
Examples #
Text Area — Character count
A status update with a 280-character limit and a live counter.
Text Area — States
Required, disabled, and loading fields.
Text Area — Validation
Error, warning, and success messages, plus an error with no message.
Text Area — Icon
Meeting notes with a pencil icon and a short description.
Keyboard controls #
The control is a real textarea, so it keeps the browser's native key behaviour, and the component only adds handling on top of a few keys. Most keystrokes therefore behave exactly as they do in any other multi-line field:
- Tab moves focus into or out of the text area.
- Shift + Enter inserts a newline at the caret.
- Enter emits the
enterevent, so your handler can take over submit-like logic. - Escape closes an open disabled reason tooltip or status tooltip.
When submit-on-Enter behaviour makes sense for your form, implement it in the enter handler.
Usage guidance #
The text area does not constrain what users type, so length limits and validation belong to your application:
- When the expected length matters, state
minlengthandmaxlengthin thedescriptionso users know it before they submit. isRequiredonly shows the required indicator and sets the matching ARIA state; it does not run native validation.- Whether the content meets your business rules is up to validation in application code.