Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Forms

Textarea

A multi-line text field with real bullet and numbered lists, the same look as Composer, and form support.

Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.

Interactive showcase

Install

Run in your project
bunx --bun @getweini/cli@latest add textarea

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Vue
<script setup lang="ts">
import { ref } from 'vue'
import Label from './components/ui/label/Label.vue'
import Textarea from './components/ui/textarea/Textarea.vue'

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

<template>
  <Label for="note">Note</Label>
  <Textarea id="note" v-model="note" :maxlength="240" resize="vertical" />
</template>

rows, maxlength, minlength, required, name, form and ARIA attributes work as on a native textarea. name, form, maxlength, minlength and autocomplete go to a hidden textarea that carries the text for forms; every other attribute goes to the editor.

When to use it

Support request

Collect a longer message while retaining native length constraints.

Resizing notes

Let authors enlarge a draft vertically without disturbing page width.

More examples

Support message

Use help text for the character limit.

Support message
<script setup lang="ts">
import { ref } from 'vue'
import Textarea from './components/ui/textarea/Textarea.vue'

const message = ref('')
</script>
<template>
  <label for="message">Message</label>
  <Textarea
    id="message"
    v-model="message"
    name="message"
    :maxlength="1000"
    required
    aria-describedby="message-help"
  />
  <p id="message-help">Up to 1,000 characters.</p>
</template>

Private notes

Choose the resize behavior; form participation and validation still work.

Private notes
<script setup lang="ts">
import { ref } from 'vue'
import Textarea from './components/ui/textarea/Textarea.vue'

const notes = ref('')
</script>
<template>
  <label for="notes">Private notes</label>
  <Textarea id="notes" v-model="notes" name="notes" :rows="6" resize="vertical" />
</template>

Lists and an expandable draft

Lists are on by default, so typing - or 1. starts a list: Enter or Ctrl/Cmd+Enter continues it, pressing either on an empty item ends it, Shift+Enter adds a line inside the item, Tab and Shift+Tab nest and outdent, and numbers stay in order. For example, Ctrl/Cmd+Enter after 1. one creates 2. ; pressing it again on that empty item creates a normal line. The same sequence works for bullet lists. Set :lists="false" to turn this off. The text stays plain markdown, so the list markers remain visible. Add expandable and messages to show a button that makes the field taller for longer writing. Press Escape and then Tab to move focus out of a list.

Lists and an expandable draft
<script setup lang="ts">
import { ref } from 'vue'
import Textarea from './components/ui/textarea/Textarea.vue'

const draft = ref('')
const messages = { expand: 'Expand editor', collapse: 'Collapse editor' }
</script>
<template>
  <label for="draft">Draft</label>
  <Textarea id="draft" v-model="draft" expandable :messages="messages" resize="none" />
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

Textarea

Complete API for Textarea
NameType or signatureDefaultWhat it does
sizepropControlSize | undefined"md"Choose the visual size. Medium is the usual default where available.
invalidpropboolean | undefinedNot setShow the invalid state; also provide a visible error message.
resizeprop"vertical" | "none" | "both" | undefined"vertical"Allow the user to change this element’s size.
expandablepropboolean | undefinedNot setAdds a button that toggles a taller editing area. Requires `messages`.
listspropboolean | undefinedtrueMarkdown-style lists: Enter or Ctrl/Cmd+Enter continues an item; Tab nests it. Default true.
messagespropTextareaMessages | undefinedNot setSupply the text this component displays for its built-in actions and states.
modelValuemodelstring | undefinedNot setCurrent value. Use v-model to keep it in sync with your page.
modelModifierspropPartial<Record<"trim" | "lazy", true>> | undefinedNot setControls the model modifiers behavior of Textarea.
update:modelValueevent[value: string | undefined]—Requests a new model value from the parent.
errorslot{ message: string; messages: string[]; }OptionalContent for the error area of Textarea.
elementexposedHTMLElement | null—Reference to the underlying HTML element.
focusexposed() => void—Move keyboard focus to this control.
expandexposed() => boolean—Access expand from a component template ref.
collapseexposed() => boolean—Access collapse from a component template ref.
Public type definitions
Public types
// packages/frameworks/vue/components/textarea/types.ts
// ------- IMPORTS -------

import type { ControlSize } from '@getweini/vue/types'

// ------- TYPES -------

export interface TextareaMessages {
  expand: string
  collapse: string
}

export interface TextareaProps {
  size?: ControlSize
  invalid?: boolean
  resize?: 'none' | 'vertical' | 'both'
  /** Adds a button that toggles a taller editing area. Requires `messages`. */
  expandable?: boolean
  /** Markdown-style lists: Enter or Ctrl/Cmd+Enter continues an item; Tab nests it. Default true. */
  lists?: boolean
  messages?: TextareaMessages
}


// packages/frameworks/vue/dist/types/index.d.ts
export type { ButtonOptions, ButtonProps } from './button';
export type ControlSize = 'sm' | 'md' | 'lg';
export interface SelectOption<T = unknown> {
    label: string;
    value: T;
    disabled?: boolean;
}
/** Application-owned copy. Bind translated strings reactively when the locale changes. */
export interface ListboxMessages {
    /** Popup name when no aria-label or aria-labelledby is supplied. */
    listboxLabel: string;
    empty: string;
    clearSelection: string;
}
export interface ListboxProps<T> {
    options: readonly SelectOption<T>[];
    messages: ListboxMessages;
    id?: string;
    disabled?: boolean;
    required?: boolean;
    invalid?: boolean;
    name?: string;
    form?: string;
    placeholder?: string;
    size?: ControlSize;
    clearable?: boolean;
    gap?: number;
    /** Supply stable equality for object values. Values must be unique. */
    by?: (a: T, b: T) => boolean;
    /** Required for meaningful form submission of object values. */
    serialize?: (value: T) => string;
}


// packages/frameworks/vue/dist/types/button.d.ts
import type { Component } from 'vue';
/** Options shared by button implementations across frameworks. */
export interface ButtonOptions<Variant extends string = string, Size extends string = string> {
    variant?: Variant;
    size?: Size;
    disabled?: boolean;
    loading?: boolean;
    type?: 'button' | 'submit' | 'reset';
}
/** Vue-specific target options extend the reusable button contract. */
export interface ButtonProps<Variant extends string = 'default' | 'secondary' | 'outline' | 'ghost' | 'destructive', Size extends string = 'sm' | 'md' | 'lg'> extends ButtonOptions<Variant, Size> {
    as?: 'button' | 'a' | Component;
    asChild?: boolean;
}

Implementation notes

  • The model supports .trim and .lazy modifiers.
  • The visible field is an editable role="textbox" (aria-multiline), so it looks and behaves like Composer. A hidden native textarea carries the text for form submission, required/maxlength validation and reset. Give it an aria-label or a <label for>: clicking the label focuses the editor.
  • Paste is always plain text; bold, italic and dropped markup are blocked. Undo and redo use the field's own history.
  • Instances read element as the editor, not a <textarea>.
  • Reset a controlled form by restoring the parent model.

Accessibility and localization

  • Connect help and error text with aria-describedby; invalid styling alone does not explain the error.

Source contract and editing guidance