Skip to content

Textarea

Basic Usage

vue
<template>
  <spr-textarea v-model="textarea" label="Description" placeholder="type here...." />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const textarea = ref('');
</script>

Display Helper

A helper message is a text label below the input field that provides additional information about instructions, formatting hints, validation feedback, etc.

To display the helper message, set the display-helper prop to true and add the helper-text prop with the helper message text. You can also insert an icon with the helper-icon prop. This uses the Iconify icon library.

This is a helper message
This is an error message
vue
<template>
  <spr-textarea
    v-model="textarea"
    label="Textarea"
    placeholder="type here...."
    display-helper
    helper-text="This is a helper message"
  />
  <spr-textarea
    v-model="textarea"
    label="Textarea"
    placeholder="type here...."
    display-helper
    helper-text="This is an error message"
    helper-icon="ph:warning-circle-fill"
    error
  />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const textarea = ref('');
</script>

Alternatively, you can use the helperMessage slot to display a custom helper message.

This is a helper message
This is an error message
vue
<template>
  <spr-textarea v-model="textarea" label="Textarea" display-helper>
    <template #helperMessage> This is a helper message </template>
  </spr-textarea>
  <spr-textarea v-model="textarea" label="Textarea" display-helper error>
    <template #helperMessage>
      <Icon icon="ph:warning-circle-fill" width="20px" height="20px" />
      <span>This is an error message</span>
    </template>
  </spr-textarea>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const textarea = ref('');
</script>

Error State

This is an error message
vue
<template>
  <spr-textarea
    v-model="textarea"
    label="Description"
    placeholder="type here...."
    display-helper
    helper-text="This is an error message"
    helper-icon="ph:warning-circle-fill"
    error
  />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const textarea = ref('');
</script>

Max Length

22/255
vue
<template>
  <spr-textarea
    v-model="textareaMaxLength"
    label="Description"
    placeholder="type here...."
    :maxLength="255"
    hasCounter
  />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const textareaMaxLength = ref('set Maximum Characters');
</script>

Disabled

vue
<template>
  <spr-textarea v-model="textarea" label="Description" placeholder="type here...." disabled />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const textarea = ref('');
</script>

Readonly

vue
<template>
  <spr-textarea v-model="textarea2" label="Description" placeholder="type here...." readonly />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const textarea2 = ref('Hello world, Sprout Design System!!!');
</script>

API Reference

Props

NameDescriptionTypeDefault
idA unique identifier for the textarea element. Used for label association and accessibility purposes.string''
modelValue / v-modelThe value of the textarea. Used with v-model directive for two-way data binding to capture and update the user's input.string''
labelThe text label displayed above the textarea to describe its purpose or content requirements.string''
supporting-labelText beside label that has a supporting stylestring''
placeholderPlaceholder text displayed inside the textarea when it's empty, providing guidance on what to enter.string''
activeWhen true, applies an active state style to the textarea. Can be used to highlight the textarea in certain application states.booleanfalse
disabledWhen true, disables the textarea, preventing user interaction and applying a disabled appearance.booleanfalse
readonlyWhen true, makes the textarea read-only, allowing users to view but not modify the content.booleanfalse
errorWhen true, applies error state styling to indicate validation issues. Often used with helper text to provide feedback.booleanfalse
minLengthSets the minimum number of characters required in the textarea. Used for HTML5 validation.numberundefined
maxLengthSets the maximum number of characters allowed in the textarea. Used for HTML5 validation and character counting.numberundefined
rowsSpecifies the visible height of the textarea in text lines. Controls the initial size of the textarea.number4
displayHelperWhen true, displays a helper message area below the textarea. Used to provide additional information or validation feedback.booleanfalse
helperIconSpecifies an icon to display alongside the helper message. Uses Iconify for icon rendering.stringnull
helperTextThe text to display in the helper message area. Provides guidance, instructions, or validation feedback.string''
hasCounterWhen true, displays a character counter showing the current length relative to maxLength. Only effective when maxLength is also specified.booleanfalse

Events

NameDescriptionParameters
update:modelValueEmitted when the textarea value changes. Used with v-model for two-way data binding.(value: string)

Slots

NameDescription
helperMessageAllows for custom content in the helper message area. Use this slot to provide formatted text, icons, or other components in the helper message area.
counterAllows for custom content in the character counter area. Use this slot to customize the appearance or behavior of the character counter.

Product Uses

Sprout HR