Skip to content

Textarea

A Vue UI kit component for Baklava's bl-textarea component with v-model support. Supports label, placeholder, validation, character counter, help text, and more.

Basic Usage

Use v-model for two-way binding with label and placeholder props.

vue
<template>
  <BvTextarea
    v-model="message"
    label="Message"
    placeholder="Enter your message"
  />
</template>

<script setup>
import { ref } from "vue";
import { BvTextarea } from "@baklavue/ui";

const message = ref("");
</script>

Rows and Maxlength

Control the visible rows and maximum character length.

vue
<template>
  <BvTextarea
    v-model="text"
    label="Description"
    :rows="6"
    :maxlength="500"
  />
</template>

<script setup>
import { ref } from "vue";
import { BvTextarea } from "@baklavue/ui";

const text = ref("");
</script>

With Validation

Use required, helpText, and invalidText for validation feedback.

vue
<template>
  <BvTextarea
    v-model="comment"
    label="Comment"
    placeholder="Enter your comment"
    :maxlength="200"
    help-text="Maximum 200 characters"
    :required="true"
  />
</template>

<script setup>
import { ref } from "vue";
import { BvTextarea } from "@baklavue/ui";

const comment = ref("");
</script>

Disabled and Readonly

Disable or make the textarea readonly.

vue
<template>
  <BvTextarea v-model="text" label="Disabled" :disabled="true" />
  <BvTextarea v-model="text" label="Readonly" :readonly="true" />
</template>

<script setup>
import { ref } from "vue";
import { BvTextarea } from "@baklavue/ui";

const text = ref("Cannot edit");
</script>

Character Counter

Enable the character counter with characterCounter.

vue
<template>
  <BvTextarea
    v-model="bio"
    label="Bio"
    :maxlength="300"
    :character-counter="true"
  />
</template>

<script setup>
import { ref } from "vue";
import { BvTextarea } from "@baklavue/ui";

const bio = ref("");
</script>

Props

PropTypeDefaultDescription
modelValuestring | nullundefinedTextarea value (v-model)
labelstringundefinedLabel text
placeholderstringundefinedPlaceholder text
rowsnumberundefinedNumber of visible rows
maxlengthnumberundefinedMaximum character length
minlengthnumberundefinedMinimum character length
disabledbooleanundefinedDisabled state
requiredbooleanundefinedRequired field
readonlybooleanundefinedReadonly state
helpTextstringundefinedHelp text below the textarea
invalidTextstringundefinedCustom error/invalid message
characterCounterbooleanundefinedEnable character counter
expandbooleanundefinedEnable auto-expand up to maxRows
maxRowsnumberundefinedMax rows when expand is true
sizeTextareaSizeundefinedTextarea size: small, medium, large
namestringundefinedName attribute for forms

Events

EventPayloadDescription
update:modelValuestring | nullEmitted when value changes (v-model)
inputCustomEventEmitted on user input
changeCustomEventEmitted when value commits (blur)

Slots

SlotDescription
defaultAdditional content/slots

Types

typescript
import type { TextareaProps, TextareaSize } from "@baklavue/ui";

type TextareaSize = "small" | "medium" | "large";

interface TextareaProps {
  modelValue?: string | null;
  label?: string;
  placeholder?: string;
  rows?: number;
  maxlength?: number;
  minlength?: number;
  disabled?: boolean;
  required?: boolean;
  readonly?: boolean;
  helpText?: string;
  invalidText?: string;
  characterCounter?: boolean;
  expand?: boolean;
  maxRows?: number;
  size?: TextareaSize;
  name?: string;
}

Usage Notes

  • v-model: Use v-model for two-way binding of the textarea value.
  • Validation: Use invalidText to display custom error messages when validation fails.
  • Character counter: Enable characterCounter with maxlength to show character count.