# Textarea

Source: https://ecosphere.dev/docs/forms/textarea (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

The multi-line field in three heights, with an optional counter.

`import { EcoTextarea } from "vue-ecosphere"`

## Textarea

Vue (vue-ecosphere):

```vue
<EcoTextarea v-model="notes" label="Notes" placeholder="What should the next person know?" first />
```

React (react-ecosphere):

```tsx
const [notes, setNotes] = useState("");

<EcoTextarea value={notes} onChange={setNotes} label="Notes" placeholder="What should the next person know?" first />
```

## With a counter

Only where a real limit exists. Type to watch the count.

Vue (vue-ecosphere):

```vue
<EcoTextarea v-model="summary" label="Summary" size="sm" :maxlength="140"
  hint="Shown at the top of the request." first />
```

React (react-ecosphere):

```tsx
const [summary, setSummary] = useState("Two checks are still running; the release is otherwise ready.");

<EcoTextarea value={summary} onChange={setSummary} label="Summary" size="sm" maxLength={140}
  hint="Shown at the top of the request." first />
```

## Filled, long

Vue (vue-ecosphere):

```vue
<EcoTextarea v-model="handover" label="Handover" size="lg" first />
```

React (react-ecosphere):

```tsx
<EcoTextarea value={handover} onChange={setHandover} label="Handover" size="lg" first />
```

## Over the limit

The counter turns is-over and the fix goes in the error beside it. Trim the text to clear it.

Vue (vue-ecosphere):

```vue
<EcoTextarea v-model="reason" label="Reason" size="sm" :maxlength="120"
  :error="reason.length > 120 ? 'Trim it to 120 characters.' : undefined" first />
```

React (react-ecosphere):

```tsx
<EcoTextarea value={reason} onChange={setReason} label="Reason" size="sm" maxLength={120}
  error={reason.length > 120 ? "Trim it to 120 characters." : undefined} first />
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `v-model` | `string` | "" | The text. |
| `size` | `"sm" \| "md" \| "lg"` | "md" | A sentence, a paragraph, a handover note. |
| `maxlength` | `number` | — | Shows the charcount, is-over past the limit. Not enforced natively. |
| `label / required / hint / error / invalid / first` | `—` | — | Field props; the error replaces the hint. |
| `placeholder / disabled / readonly / id` | `—` | — | Native textarea attributes. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `value / onChange` | `string` | "" | The text. |
| `size` | `"sm" \| "md" \| "lg"` | "md" | A sentence, a paragraph, a handover note. |
| `maxLength` | `number` | — | Shows the charcount, is-over past the limit. Not enforced natively (never set on the <textarea>). |
| `label / required / hint / error / invalid / first` | `—` | — | Field props; the error replaces the hint. |
| `placeholder / disabled / readOnly / id` | `—` | — | Native textarea attributes; other textarea props and the ref go to the <textarea>. |
