# Textarea

Multi-line text control with the same states as Input.

Docs: https://corsairui.vercel.app/docs/textarea

## Install

```bash
pnpm dlx shadcn@latest add @corsair-ui/textarea
```

Also adds: `utils`.
npm: `clsx`, `tailwind-merge`.

## Styling

Restyle it in the project that installs it: `className` on each part, the theme variables, and these attributes with arbitrary variants (`[&_[data-slot=…]]:…`, `data-[state=…]:…`).

data-slot: `textarea`

## Accessibility

- The error style comes from aria-invalid="true".

## Examples

On the docs page: Default, Invalid, Disabled. The usage examples in the source comments below are the reference.

## Source

What `shadcn add` writes into the project:

### textarea.tsx

```tsx
import type { ComponentProps } from "react";

import { cn } from "@/registry/default/lib/utils";

/** Multi-line text control with the same states as Input. */
function Textarea({ className, ...props }: ComponentProps<"textarea">) {
  return (
    <textarea
      data-slot="textarea"
      className={cn(
        "border-input bg-field flex min-h-16 w-full resize-y rounded-md border px-3 py-2 text-base md:text-sm",
        "transition-[color,border-color,box-shadow] outline-none motion-reduce:transition-none",
        "placeholder:text-muted-foreground",
        "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
        "aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/20",
        "disabled:cursor-not-allowed disabled:opacity-50",
        className
      )}
      {...props}
    />
  );
}

export { Textarea };
```
