PXD

Textarea

Retrieve multi-line user input.

Default

<template>
  <PTextarea
    rows="4"
    placeholder="Please enter your text here..."
  />
</template>

Disabled

<template>
  <PTextarea
    disabled
    rows="4"
    placeholder="Please enter your text here..."
  />
</template>

Error

<script setup>
import { ref } from 'vue'

const value = ref(
  'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
)
</script>

<template>
  <PStack gap="12" direction="vertical">
    <PTextarea v-model="value" size="xs" error="There has been an error." />
    <PTextarea v-model="value" size="sm" error="There has been an error." />
    <PTextarea v-model="value" size="md" error="There has been an error." />
    <PTextarea v-model="value" size="lg" error="There has been an error." />
  </PStack>
</template>

Word Limit

<script setup>
import { ref } from 'vue'

const insideValue = ref('Hello')
const outsideValue = ref('Hello')
</script>

<template>
  <PStack direction="vertical">
    <PTextarea
      v-model="insideValue"
      rows="4"
      max-length="100"
      show-word-limit
      placeholder="Word limit inside"
    />
    <PTextarea
      v-model="outsideValue"
      rows="4"
      max-length="100"
      show-word-limit
      word-limit-position="outside"
      placeholder="Word limit outside"
    />
  </PStack>
</template>

Props

NameTypeDefaultDescription
rowsstring | number-Visible height in text rows
colsstring | number-Visible width in characters
size'xs' | 'sm' | 'md' | 'lg'-Font size, falls back to the ConfigProvider size
errorboolean | string-Show the error style, also applied when the word limit is exceeded
readonlyboolean-Native readonly attribute, the value stays selectable
disabledboolean-Native disabled attribute, blocks editing and focus
autofocusboolean-Focus the field as soon as it is mounted
min-lengthnumber | string-Native minlength attribute, validated by the browser
max-lengthnumber | string-Native maxlength, lifted while composing and shown by the word limit
trim-overflowbooleanfalseTrim overflow value after composition ends when max-length is set.
model-valuestring | number | null``Bound value, emitted on every keystroke
placeholderstring-Placeholder text shown while the value is empty
show-word-limitboolean | string-Show the character counter, count / max when max-length is set
word-limit-position'inside' | 'outside'insidePlace the counter inside the field or below it

Events

NameTypeDescription
update:modelValue(value: string | number) => voidEmitted on every keystroke that changes the text.
change(value: string | number) => voidEmitted when the field is committed, as the browser fires its native change event.
focus(event: FocusEvent) => voidEmitted when the textarea gains focus.
blur(event: FocusEvent) => voidEmitted when the textarea loses focus.

Source

Source