vael-ui v0.5.7

Forms & inputs

Layout

Textarea

A multi-line text field that can grow with its content. Use it for comments, notes and other long text.

Validating a form? vael-form wires this up with a schema

Install

import { Textarea } from 'vael-ui'

Playground

Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Textarea } from 'vael-ui'

const value = ref('')
</script>

<template>
  <Textarea placeholder="Type here…" v-model="value" />
</template>

Props

NameTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Control size.
disabledbooleanfalseDisables the textarea and blocks interaction. A disabled parent Field also disables it.
readonlybooleanfalseMakes the value read-only while keeping it focusable and selectable.
invalidbooleanfalseStandalone override; ORed with the nearest Field's error state.
placeholderstringText shown while the textarea is empty.
rowsnumber3Native rows attribute; also sets the auto-grow minimum.
autoGrowbooleanfalseGrows the textarea to fit its content.
maxRowsnumberMaximum rows autoGrow grows to; unset means no cap.
motionTextareaMotionHow it moves: its appearance ({ initial: { root: { opacity: 0, y: 4 } } }) and its states ({ states: { invalid: { root: { x: [0, -6, 6, 0] } } } }). false turns its own animation off.
uiPartial<Record<'root' | 'textarea' | 'start' | 'end' | 'bottomStart' | 'bottomEnd', UiPartValue>>Class and style overrides for each part.
modelValuestring''Textarea value. Supports the .trim and .lazy modifiers.

Events

NameTypeDescription
update:modelValue(value: string)Fires when modelValue changes (v-model).

Slots

NameTypeDescription
startanyInline leading content (centered on the resting height).
endanyInline trailing content (centered on the resting height).
bottom-startanyBottom-left of the action strip, such as an attachment button.
bottom-endanyBottom-right of the action strip, such as a character counter or send button.
display{ value: string; placeholder: string; focused: boolean; }Draws the text yourself, over the textarea's own text and following its wrapping and scroll, for highlighted mentions, tags or syntax. The textarea underneath keeps the caret, selection and screen reader text; its own text is hidden. Give an element pointer-events: auto to let it take hover.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element (the frame around the textarea).
textareaElHTMLTextAreaElement | nullNative <textarea> element.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Textarea: its appearance and states.

<Textarea
  :motion="{ states: { invalid: { root: { scale: 1.04 } } } }"
/>
NameTypeDescription
initialexitroottextareaSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
statesinvaliddisabledfocusSets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

It has no keyboard interaction of its own.

  • Renders a native <textarea> and adds no keys of its own.
  • Inside a Field, the label names it. aria-describedby lists your own ids first, then the Field’s description and error.
  • Outside a Field, give it an aria-label, which goes to the textarea. It sets aria-invalid when invalid and aria-required when the Field is required.
  • The #display slot is aria-hidden; screen readers read the textarea underneath.