Textarea
Multi-line text input. Shares the variant and validation model with Input so both can be mixed in a form without restyling.
When to use
- Long-form text — comments, descriptions, notes, feedback.
- Structured input — addresses, multi-line data entry.
When NOT to use
- For single-line text — use Input.
- For rich text editing — use a dedicated rich-text editor.
Import
import { Textarea } from '@mihcm/ui/Textarea';
import { Label } from '@mihcm/ui/Label';Basic usage
<div className="space-y-1.5">
<Label htmlFor="comment">Comment</Label>
<Textarea id="comment" placeholder="Write your comment..." />
</div>Variants
| Variant | Use when |
|---|---|
default | Standard text entry. |
destructive | Validation error state. Auto-applied when invalid is set. |
Props
| Prop | Default | Description |
|---|---|---|
variant | "default" | Visual style. |
invalid | false | Sets aria-invalid and switches to destructive styling. |
rows | 3 | Initial visible rows. |
required | false | Sets aria-required. |
The textarea is vertically resizable by default (resize-y).
Composition
- Always pair with a Label via
htmlForfor accessibility. - Set
invalidto show destructive styling. Pair with an error message below the field. - The textarea is vertically resizable by default (
resize-y). PassclassName="resize-none"to disable. - For rich text formatting (bold, links, lists), use RichTextEditor instead.
Related
- Input — single-line text field.
- RichTextEditor — formatted multi-line editor.
- Label — always pair with Textarea.
- Form — form field integration.