WlTextarea

Multiline field. autoResize can adjust its height to content.
Components / Inputs v0.1.0

Size and density

Full example
<div class="wl-stack" data-space="md">
  <WlTextarea
    v-model="value"
    aria-label="Material description"
    :rows="3"
    auto-resize
    
  />
</div>

States

Full example
<div class="wl-stack" data-space="md">
  <WlTextarea
    v-model="value"
    aria-label="Material description"
    :rows="3"
    auto-resize
    
  />
</div>

Rows, height and error

Fixed height through rows or content height through autoResize. Shared model, adding rows, required comment and clearing.

Fixed rows and content height

Add lines: the height grows with the text.

Error and unavailable field

Add a comment.

Description length: 45 characters.

Full example
<script setup lang="ts">
import { WlButton, WlField, WlTextarea } from "legato-ui";
import { ref } from "vue";
const text = ref("Briefly describe the task.\nAdd the next step.");
const comment = ref("");
</script>

<template>
  <div class="wl-stack" data-space="xl" data-input-example="WlTextarea">
    <section class="wl-stack" data-space="md">
      <h3 class="wl-text-subheading">{{ "Fixed rows and content height" }}</h3>
      <div class="wl-grid" data-space="lg">
        <WlField id="docs-textarea-fixed" v-slot="{ id }" label="Description, 4 rows">
          <WlTextarea :id="id" v-model="text" :rows="4" />
        </WlField>
        <WlField
          id="docs-textarea-grow"
          v-slot="{ id, ariaDescribedby }"
          label="Description with content height"
          hint="Add lines: the height grows with the text."
        ><WlTextarea
          :id="id"
          v-model="text"
          :rows="2"
          auto-resize
          :aria-describedby="ariaDescribedby"
        /></WlField>
      </div>
    </section>
    <section class="wl-stack" data-space="md">
      <h3 class="wl-text-subheading">{{ "Error and unavailable field" }}</h3>
      <div class="wl-grid" data-space="lg">
        <WlField
          id="docs-textarea-comment"
          v-slot="{ id, ariaDescribedby, invalid, required }"
          label="Comment"
          :error="comment.trim() ? undefined : 'Add a comment.'"
          required
        ><WlTextarea
          :id="id"
          v-model="comment"
          :invalid="invalid"
          :required="required"
          :aria-describedby="ariaDescribedby"
          placeholder="What needs clarification?"
        /></WlField>
        <WlField id="docs-textarea-disabled" v-slot="{ id }" label="Closed comment">
          <WlTextarea :id="id" model-value="Discussion completed." disabled />
        </WlField>
      </div>
      <div class="wl-inline" data-space="sm">
        <WlButton size="sm" @click="text += '\nAnother item.'">{{ "Add line" }}</WlButton>
        <WlButton size="sm" @click="text = ''; comment = ''">{{ "Clear text" }}</WlButton>
      </div>
      <p class="wl-text-small" role="status">{{
        "Description length:"
      }} {{
        text.length
      }} {{
        "characters."
      }}</p>
    </section>
  </div>
</template>