Support request
Collect a longer message while retaining native length constraints.
Components / Forms
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.
bunx --bun @getweini/cli@latest add textareaImport 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.
<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.
Collect a longer message while retaining native length constraints.
Let authors enlarge a draft vertically without disturbing page width.
Use help text for the character limit.
<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>Choose the resize behavior; form participation and validation still work.
<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 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.
<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>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.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
sizeprop | ControlSize | undefined | "md" | Choose the visual size. Medium is the usual default where available. |
invalidprop | boolean | undefined | Not set | Show the invalid state; also provide a visible error message. |
resizeprop | "vertical" | "none" | "both" | undefined | "vertical" | Allow the user to change this element’s size. |
expandableprop | boolean | undefined | Not set | Adds a button that toggles a taller editing area. Requires `messages`. |
listsprop | boolean | undefined | true | Markdown-style lists: Enter or Ctrl/Cmd+Enter continues an item; Tab nests it. Default true. |
messagesprop | TextareaMessages | undefined | Not set | Supply the text this component displays for its built-in actions and states. |
modelValuemodel | string | undefined | Not set | Current value. Use v-model to keep it in sync with your page. |
modelModifiersprop | Partial<Record<"trim" | "lazy", true>> | undefined | Not set | Controls the model modifiers behavior of Textarea. |
update:modelValueevent | [value: string | undefined] | — | Requests a new model value from the parent. |
errorslot | { message: string; messages: string[]; } | Optional | Content for the error area of Textarea. |
elementexposed | HTMLElement | 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. |
// 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;
}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.element as the editor, not a <textarea>.