# Textarea

> Multi-line text that grows with its content, then scrolls.

Category: Inputs · Atomic level: atom · Built on Base UI Field.Control
Page: https://ui.dtheo.dev/docs/components/textarea

## Install

```bash
npx dtheo@latest add textarea
# or, with the shadcn CLI
npx shadcn@latest add https://ui.dtheo.dev/r/textarea.json
```

Dependencies: @base-ui/react, clsx, tailwind-merge. Registry dependencies: utils, input.

## Exports

`Textarea`

## Use it for

- Notes, descriptions, review comments

## Reach for something else

- Single values (an ID, a name): use Input
- Structured data people will filter on: use fields

## Examples

### textarea

```tsx
import * as React from 'react';
import { Button } from '@/components/ui/button';
import { Field, FieldDescription, FieldLabel } from '@/components/ui/field';
import { Textarea } from '@/components/ui/textarea';
import { useToast } from '@/components/ui/toast';

const MAX = 600;

export default function TextareaExample() {
  const toast = useToast();
  const [note, setNote] = React.useState(
    'Overshoot 17.6 % is over the 15 % limit. Kp 4.20 is too aggressive for the 2 kg load; suggest Kp 3.60 and a rerun on Bench 3.',
  );
  return (
    <div className="flex w-full max-w-md flex-col gap-3">
      <Field>
        <FieldLabel>Review note</FieldLabel>
        <Textarea value={note} maxLength={MAX} onChange={(e) => setNote(e.target.value)} />
        <div className="flex items-baseline justify-between gap-3">
          <FieldDescription>Reviewers see this on R-0412.</FieldDescription>
          <span className="text-caption text-subtle-foreground tabular-nums">
            {note.length}/{MAX}
          </span>
        </div>
      </Field>
      <div className="flex justify-end gap-2">
        <Button variant="ghost" onClick={() => setNote('')}>
          Discard
        </Button>
        <Button
          variant="primary"
          disabled={!note.trim()}
          onClick={() => {
            toast.add({
              title: 'Note posted',
              description: 'Reviewers on R-0412 were notified.',
              type: 'success',
            });
            setNote('');
          }}
        >
          Post note
        </Button>
      </div>
    </div>
  );
}
```

## Used in

- Run review (page): https://ui.dtheo.dev/examples/run-review
- Forms pattern (template): https://ui.dtheo.dev/docs/patterns/forms
