Skip to content

Textarea

Multi-line text input field for longer text entry.

Import

ts
import { Textarea } from '@heroui-vue/vue'

Usage

Basic

<template>
  <div class="flex flex-col gap-3">
    <Textarea placeholder="Write something..." :rows="3" />
    <Textarea variant="secondary" placeholder="Secondary variant" :rows="3" />
    <Textarea placeholder="Disabled" :disabled="true" :rows="3" />
  </div>
</template>

<script setup>
import { Textarea } from '@heroui-vue/vue'
</script>

Controlled

vue
<script setup lang="ts">
import { ref } from 'vue'
import { Textarea } from '@heroui-vue/vue'

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

<template>
  <div class="flex flex-col gap-2">
    <label for="message">Message</label>
    <Textarea id="message" v-model="message" placeholder="Enter your message" />
    <p class="text-sm text-gray-600">Characters: {{ message.length }}</p>
  </div>
</template>

Rows

Control the height with the rows prop:

vue
<template>
  <Textarea :rows="3" placeholder="3 rows" />
  <Textarea :rows="5" placeholder="5 rows" />
  <Textarea :rows="8" placeholder="8 rows" />
</template>

Disabled

vue
<template>
  <Textarea :disabled="true" placeholder="Disabled textarea" />
</template>

Resize

Control resize behavior:

vue
<template>
  <Textarea class="resize-none" placeholder="Cannot be resized" />
  <Textarea class="resize-y" placeholder="Resize vertically" />
  <Textarea class="resize" placeholder="Resize both ways" />
</template>

API

Props

PropTypeDefaultDescription
placeholderstringundefinedPlaceholder text
rowsnumber4Number of visible text rows
disabledbooleanfalseWhether the textarea is disabled
readonlybooleanfalseWhether the textarea is read-only
requiredbooleanfalseWhether the textarea is required
modelValuestringundefinedv-model value

Events

EventPayloadDescription
update:modelValuestringEmitted when textarea value changes
inputInputEventNative input event
changeEventNative change event
focusFocusEventEmitted when textarea receives focus
blurFocusEventEmitted when textarea loses focus

Accessibility

  • Proper label association with id and for attributes
  • Keyboard navigation support
  • Screen reader friendly
  • Focus visible indicator

Released under the Apache-2.0 License.