Components
Textarea
A multi-line text field that grows with its content.
Installation
$ npx veil-ui@latest add textareaUsage
import { Textarea } from "@/components/ui/textarea";
<Textarea placeholder="Tell us more" />;Examples
Basic
With label
Displayed on your public profile.
Invalid
Message must be at least 20 characters.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| rows | number | — | Initial height in lines. The field also grows with field-sizing. |
| aria-invalid | boolean | — | Switches the border and ring to the destructive token. |
| ...props | React.ComponentProps<"textarea"> | — | All native textarea attributes. |
Accessibility
- Provide a visible
<Label>or anaria-label. - When invalid, set
aria-invalidand connect the message witharia-describedby. - Avoid disabling submit buttons without explaining why in text.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add textarea --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { computed } from "vue";
import { cn } from "@/lib/utils";
const props = defineProps<{
class?: string;
modelValue?: string | number;
}>();
const emit = defineEmits<{ "update:modelValue": [value: string] }>();
const value = computed(() => props.modelValue ?? "");
</script>
<template>
<textarea
:value="value"
data-slot="textarea"
:class="
cn(
'flex min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow,border-color]',
'placeholder:text-muted-foreground',
'focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50',
'aria-invalid:border-destructive aria-invalid:ring-destructive/20',
'disabled:cursor-not-allowed disabled:opacity-50',
'field-sizing-content dark:bg-input/30',
props.class,
)
"
@input="
emit('update:modelValue', ($event.target as HTMLTextAreaElement).value)
"
/>
</template>