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

NameDescriptionTypeAvailable ValuesDefault
idSpecifies the unique identifier for the textarea.String-''
modelValueSpecifies the value of the textarea.String-''
labelSpecifies the label for the textarea.String-''
placeholderSpecifies the placeholder text for the textarea.String-''
activeIndicates whether the textarea is active.Booleantrue, falsefalse
disabledDisables the textarea.Booleantrue, falsefalse
readonlySets the textarea to read-only mode.Booleantrue, falsefalse
errorIndicates whether the textarea is in an error state.Booleantrue, falsefalse
minLengthSpecifies the minimum length of the textarea value.Number--
maxLengthSpecifies the maximum length of the textarea value.Number--
rowsSpecifies the number of rows for the textarea.Number-4
displayHelperEnables the display of a helper message below the textarea.Booleantrue, falsefalse
helperIconSpecifies the icon to display alongside the helper message.String-null
helperTextSpecifies the helper message text.String-''
hasCounterSpecifies the counter for maximum character.Number-''

Product Uses

Sprout HR