# Textarea

> A multi-line text field that shares the Input label, helper and error pattern.

Use a textarea for longer text such as a comment, a bio or release notes. It is three lines tall by default and people can drag it taller.

```tsx
import { Textarea } from "@aloxe/react";

export default function TextareaBasic() {
  return (
    <Textarea
      label="Release notes"
      name="notes"
      placeholder="What changed in this version"
      description="Shown to everyone who installs the update."
      className="w-full max-w-md"
    />
  );
}
```

## Installation

```bash
npm i @aloxe/react @aloxe/tokens
```

Then add the CSS imports from [Installation](/docs/getting-started/installation).

## Usage

```tsx
import { Textarea } from "@aloxe/react";

<Textarea label="Release notes" name="notes" />
```

Native textarea props such as `name`, `maxLength` and `ref` go to the `<textarea>`. `className` styles the wrapper.

## Examples

### States

`error` sets the error state and links the message to the field. `disabled` dims it and turns off resizing.

```tsx
import { Textarea } from "@aloxe/react";

export default function TextareaStates() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <Textarea
        label="Bio"
        rows={2}
        error="Keep it under 160 characters."
        defaultValue="Designer and engineer in Lisbon."
      />
      <Textarea
        label="Internal notes"
        rows={2}
        disabled
        defaultValue="Only admins can edit this field."
      />
    </div>
  );
}
```

### Controlled

A controlled textarea can show what's left of a limit in the description. The error appears only once the text goes over.

```tsx
"use client";

import { Textarea } from "@aloxe/react";
import { useState } from "react";

const LIMIT = 160;

export default function TextareaControlled() {
  const [bio, setBio] = useState("");
  const left = LIMIT - bio.length;

  return (
    <Textarea
      label="Bio"
      value={bio}
      onChange={(event) => setBio(event.target.value)}
      description={`${left} characters left`}
      error={left < 0 ? `${-left} characters over the limit` : undefined}
      className="w-full max-w-md"
    />
  );
}
```

## Accessibility

| Key | Action |
| --- | --- |
| Tab | Moves focus to the textarea. |
| Enter | Adds a new line; it does not submit the form. |

- The label is the accessible name, and `description` and `error` are linked with `aria-describedby`.
- If you show a character count, put it in `description` so it is read with the field.

## API reference

Every part accepts `className` and renders a `data-aloxe` attribute you can target in CSS, such as `[data-aloxe="textarea"]`.

**Textarea** (extends Base UI Field; other props go to the native <textarea>)

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `label` | `ReactNode` |  | Yes | The visible label and the textarea's accessible name. |
| `showLabel` | `boolean` | `true` |  | false hides the label visually only. Screen readers still announce it. |
| `description` | `ReactNode` |  |  | Helper text under the textarea, linked with aria-describedby. |
| `error` | `ReactNode` |  |  | Error message. Sets the error state and links the message to the textarea. |
| `rows` | `number` | `3` |  | Initial height in lines. Users can resize vertically. |
| `disabled` | `boolean` | `false` |  | Disables the textarea and turns off resizing. |
| `className` | `string` |  |  | Classes for the wrapper. Other props go to the <textarea>. |

## Figma

Matches the **Textarea** component. Figma `Label`, `Value` and `Helper` map to `label`, `value` and `description`; `Show label` maps to `showLabel`. The Error state is the `error` prop.

See [Figma](/docs/getting-started/figma) for where to get the file and how its names map to code.
