Textarea
Web/MobileA multi-line text control with optional leading icons. Resize from the corner; pair with your own label and help text.
یادداشت شما ذخیره میشود.
Installation
pnpm dlx cubix-ui@latest add textarea --base ariaUsage
import { Textarea, TextareaControl } from "@/components/cubix/textarea"
<div className="grid w-full max-w-sm gap-2">
<label
htmlFor="textarea-demo"
className="w-fit text-label leading-none font-normal text-foreground"
>
یادداشت
</label>
<TextareaControl>
<Icon data-icon="inline-start" />
<Textarea
id="textarea-demo"
placeholder="یادداشت خود را بنویسید..."
defaultValue="جلسه فردا ساعت ۱۰ - آمادهسازی گزارش ماهانه."
/>
</TextareaControl>
<p className="text-caption text-muted-foreground">یادداشت شما ذخیره میشود.</p>
</div>
Composition
Wrap Textarea in TextareaControl when you need a bordered surface, icons, or the resize grip. Label and help text stay outside the control so you can wire htmlFor and live regions yourself.
TextareaControl
├── Icon data-icon="inline-start" | "inline-end"
└── TextareaAccessibility
Associate a visible label with the textarea via htmlFor and id. Pass aria-invalid for error styles, and keep helper or error copy in a sibling element that you can wire with aria-describedby.
Examples
Label and description
Pair the control with a native label and caption for a complete field.
پیام شما به تیم پشتیبانی ارسال میشود.
Icons
Place icons inside TextareaControl with data-icon like Button so spacing follows the reading direction.
Height
Override the minimum height with className on Textarea. The corner grip still resizes within the control.
Invalid
Set aria-invalid on the textarea to apply destructive styles, and show your own error copy below.
بیوگرافی باید حداقل ۱۰ کاراکتر باشد.
Disabled
Disable the textarea to block editing. The control uses a muted fill; label and description stay readable.
این فیلد فعلاً قابل ویرایش نیست.
In a form
Set name on Textarea so the value is submitted with the form, and pair it with Cubix Button.
Custom styling
Every part accepts a className merged with the shipped cn helper. Here the control uses a filled surface instead of the default outline.
API Reference
Note: Parts render data-slot attributes (textarea, textarea-control) for targeting in tests and parent selectors. Use the same props on Base UI, React Aria, and Radix.
Textarea
| Prop | Type | Default | Description |
|---|---|---|---|
| aria-invalid | boolean | - | Marks the textarea as invalid and applies destructive border and ring styles automatically. |
| disabled | boolean | false | Disables the textarea and prevents interaction. Uses a muted fill and opacity-70 so the value stays readable. |
| placeholder | string | - | Hint text shown when the textarea is empty (styled with muted-foreground). |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). Use for custom height, fill, or resize. |
| ...props | React.ComponentProps<'textarea'> | - | All native textarea attributes (value, onChange, required, rows, maxLength, ...) are forwarded to the rendered element. |
TextareaControl
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | - | Wrap Textarea with an icon marked data-icon="inline-start" (same as Button / Text Field). The icon aligns to the top for multiline content. |
| className | string | - | Additional Tailwind classes merged with the control styles (last one wins). |