Text Area

Alignment target:@astryxdesign/core v0.7.1 · TextArea

<TextArea
  label="Notes"
  :model-value="Reply before 3pm."
  size="md"
/>

Props #

PropTypeDefaultDescription
v-modelstring—Required. Text content.
labelstring—Required. Field name.
idstring—Prefix for associated IDs. Auto-generated when omitted.
size'sm' | 'md' | 'lg'mdText area height.
rowsnumber—Native textarea rows.
colsnumber—Native textarea cols.
minlengthnumber | string—Native textarea minlength.
maxlengthnumber | string—Visible-character limit. One emoji counts as one. Typing past it stays allowed; the count turns red, and screen readers hear the near and over zones. It is not written to the native maxlength attribute.
wrap'soft' | 'hard'softNative textarea wrap.
resize'none' | 'both' | 'horizontal' | 'vertical'verticalNative textarea resize. Vertical dragging is enabled by default.
autoCompletestring—Native textarea autocomplete token, such as off or email. Forwarded unchanged; the controlled value is not affected.
hasSpellCheckbooleantrueTurns the browser spell checker on or off for the textarea.
placeholderstring—Placeholder text.
descriptionstring—Description below the label.
isLabelHiddenbooleanfalseHide the visual label. Keep the accessible name.
isDisabledbooleanfalsePrevent edits. Do not submit the form value.
disabledMessagestring—Reason for disabling. The disabled text area stays focusable when provided.
isReadOnlybooleanfalsePrevent edits. Include the value in form submission.
isRequiredbooleanfalseShow a required description. Does not run native required validation.
isOptionalbooleanfalseShow an optional description. Takes precedence over isRequired.
requiredLabelstringRequiredRequired description text.
optionalLabelstringOptionalOptional description text.
widthnumber | string—Width of the whole field. Numbers are treated as px.
htmlNamestring—Native textarea name.
formstring—ID of the associated form.
statusFieldStatusInput—Error, warning, or success status.
statusVariant'attached' | 'detached' | 'tooltip'detachedHow the status message is displayed. Text area defaults to below the control.
changeAction(value: string, event) => void | Promise<void>—Action to run after content changes.
isLoadingbooleanfalseShow a loading indicator.
hasClearbooleanfalseShow a clear button.
hasAutoFocusbooleanfalseFocus on mount.
clearLabelstring—Accessible name of the clear button. It includes the field label by default. The tooltip only says “Clear”.
containerClassstring | object | array—Class for the field container. Has no effect, and warns in development, inside InputGroup and in a horizontal-labels FormLayout.
containerStyleStyleValue—Inline style for the field container.
controlClassstring | object | array—Class for the text area box. A class written on the component lands here too, with no warning.
controlStyleStyleValue—Inline style for the text area box. A style written on the component lands here too.
loadingLabelstringLoadingAccessible label for the loading indicator.
labelIconComponent—Decorative icon before the label.
labelTooltipstring—Info tooltip beside the label.

Events #

  • update:modelValue(value):update text content.
  • change(value, event):fired when content changes.
  • clear(event):fired when the clear button is clicked.
  • enter(event):fired on Enter. Shift + Enter does not fire it.
  • keydown(event):fired on any key press.
  • actionError(error, value, event):fired when changeAction throws.

When content changes, update:modelValue and change fire before changeAction. Cancelling the change event prevents changeAction from running.

Native attributes #

  • class, style, and other attributes are applied to the field wrapper.
  • aria-labelledby and aria-describedby are merged into the native textarea.
  • focus, blur and paste listeners land on the native textarea.
  • The component manages disabled, readonly, spellcheck, and aria-invalid.
  • The icon slot shows a decorative icon on the left.
  • The end slot shows extra content on the right.
  • The labelIcon slot replaces the icon before the label.

Theming #

CSS
.my-text-area {
  --astryx-text-area-min-height-md: 120px;
}
  • --astryx-text-area-min-height-sm: minimum height for the sm size.
  • --astryx-text-area-min-height-md: minimum height for the md size.
  • --astryx-text-area-min-height-lg: minimum height for the lg size.

Other color and border variables are shared with TextInput. Neutral adapts to light and dark modes.