Textarea

Web/Mobile

A 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 aria

Usage

Import
import { Textarea, TextareaControl } from "@/components/cubix/textarea"
Example
<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.

Structure
TextareaControl
├── Icon data-icon="inline-start" | "inline-end"
└── Textarea

Accessibility

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

PropTypeDefaultDescription
aria-invalidboolean-Marks the textarea as invalid and applies destructive border and ring styles automatically.
disabledbooleanfalseDisables the textarea and prevents interaction. Uses a muted fill and opacity-70 so the value stays readable.
placeholderstring-Hint text shown when the textarea is empty (styled with muted-foreground).
classNamestring-Additional Tailwind classes merged with the component styles (last one wins). Use for custom height, fill, or resize.
...propsReact.ComponentProps<'textarea'>-All native textarea attributes (value, onChange, required, rows, maxLength, ...) are forwarded to the rendered element.

TextareaControl

PropTypeDefaultDescription
childrenReact.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.
classNamestring-Additional Tailwind classes merged with the control styles (last one wins).