> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Textarea

A multi-line text field that grows with its content, with an optional label, helper text and error message.


## Installation

```bash
npx @blotch/dolan add textarea
```

```typescript
import { UiTextarea } from '../components/ui/textarea';
```

## Usage

```typescript title="src/app/app.ts"
import { Component, signal } from '@angular/core';
import { UiTextarea } from '../components/ui/textarea';

@Component({
  selector: 'app-root',
  imports: [UiTextarea],
  template: `
    <ui-textarea
      label="Bio"
      placeholder="Tell us about yourself"
      [(value)]="bio"
    />
  `,
})
export class App {
  protected readonly bio = signal('');
}
```

- `[(value)]` updates your signal on every keystroke. Setting the signal from code updates the field too.
- The field opens three lines tall and grows as the user types.
- `class` styles the whole block of label, field and message.

### Height limits

```angular-html
<ui-textarea label="Review" [minLines]="3" [maxLines]="6" [(value)]="review" />
<ui-textarea label="Note" [minLines]="1" [maxLines]="4" [(value)]="note" />
```

- `minLines` sets the starting height.
- `maxLines` stops the growth. Past it, the field scrolls and shows a scroll bar. Without it, the field keeps growing.
- Each line is 20 pixels, the line height of the field's text.

### Helper text and errors

```angular-html
<ui-textarea
  label="Feedback"
  helperText="Helps us improve"
  [(value)]="feedback"
/>
<ui-textarea
  label="Description"
  error="Description is required"
  [(value)]="description"
/>
```

A non-empty `error` replaces the helper text with red text and turns the focus ring red. The field shakes when an error first appears.

### Disabled

```angular-html
<ui-textarea label="System notes" value="Read only" disabled />
```

### Signal Forms

`UiTextarea` implements Angular's `FormValueControl`, so `[formField]` works on it the same way as on [Input](/dolan/input.md#signal-forms). It emits `touch` when the field loses focus, so the field counts as touched and an error can show as soon as the user leaves it, as on an input. A form's `maxLength()` and `readonly()` reach the field, and `focusBoundControl()` focuses it.

## API

### UiTextarea

| Input                 | Type                  | Default     | Description                                                                   |
| --------------------- | --------------------- | ----------- | ----------------------------------------------------------------------------- |
| `value`               | `string`              | `''`        | The text. Supports `[(value)]`.                                               |
| `label`               | `string`              | `''`        | Text above the field. Hidden when empty.                                      |
| `accessibility-label` | `string`              | `''`        | The field's name for screen readers when it has no `label`.                   |
| `placeholder`         | `string`              | `''`        | Hint shown while the field is empty.                                          |
| `helperText`          | `string`              | `''`        | Muted text under the field. Hidden while `error` is set.                      |
| `error`               | `string`              | `''`        | Error text. Turns the ring red and shakes the field.                          |
| `disabled`            | `boolean`             | `false`     | Dims the field and ignores typing.                                            |
| `minLines`            | `number`              | `3`         | Starting height, in lines.                                                    |
| `maxLines`            | `number \| undefined` | `undefined` | Height at which the field stops growing and scrolls.                          |
| `class`               | `string`              | `''`        | Extra Tailwind classes for the outer block.                                   |
| `maxLength`           | `number`              | —           | The most characters the field takes. Signal Forms sets it from `maxLength()`. |
| `readonly`            | `boolean`             | `false`     | The text can't be changed. Signal Forms sets it from `readonly()`.            |

| Output        | Type     | Description                                         |
| ------------- | -------- | --------------------------------------------------- |
| `valueChange` | `string` | Emits the text on every keystroke, for `[(value)]`. |
| `changed`     | `string` | Emits the text on every keystroke.                  |
| `focused`     | `void`   | Emits when the field gains focus.                   |
| `blurred`     | `void`   | Emits when the field loses focus.                   |
| `touch`       | `void`   | Emits when the field loses focus, for forms.        |

## Accessibility

- **A screen reader reads the field with its `label`,** which becomes the native `<textarea>`'s `accessibility-label`, and then the text in it. The label above the field isn't a stop of its own, so it isn't read twice.
- **A field without a `label` takes its name from `accessibility-label`,** for a textarea under a label of your own. Without either, a screen reader reads only the placeholder. `label` wins when both are set.
- **Tests find it by its label too:** `getByRole('textbox', { name: 'Notes' })` returns the `<textarea>`.

## Related

- [Input](/dolan/input.md): a single-line field
- [Forms](/guide/forms.md): forms and the on-screen keyboard
- [`<textarea>`](/api/elements/textarea.md): the element underneath
