# Textarea

Page: /docs/components/textarea

{/* Figma: Meridian → Textarea (docs 33:20, component set 20:7700). Spec: docs/design-system/meridian/textarea.md */}

Multi-line text, the same field as Input: label, description and error built in, the same border and focus glow, a 16 value and a 14 label. It grows with what people type. On the site it is the message field on demo and contact forms.

```tsx
import { TextArea } from "@commenda/meridian/ui/textarea";
import type { ReactNode } from "react";

function Fields({ children, cols = 2 }: { children: ReactNode; cols?: 2 | 3 }) {
	return (
		<div
			className={`not-prose my-4 grid gap-6 rounded-xl border border-fd-border bg-white p-8 ${
				cols === 3 ? "md:grid-cols-3" : "md:grid-cols-2"
			}`}
		>
			{children}
		</div>
	);
}

const HELP =
	"We sell in 30 US states and just crossed nexus in Texas. We need help registering and filing.";

export function TextareaField() {
	return (
		<Fields>
			<TextArea
				label="How can we help?"
				placeholder="e.g. We sell in 30 US states and need to register for sales tax"
			/>
			<TextArea
				label="How can we help?"
				defaultValue={HELP}
				description="A few lines help us bring the right expert to the call."
			/>
		</Fields>
	);
}
```

## Usage [#usage]

```tsx
import { TextArea } from "@commenda/meridian/ui/textarea";

<TextArea label="How can we help?" placeholder="e.g. We sell in 30 US states and need to register for sales tax" />;
```

## Field [#field]

For anything that might take two sentences or more: what a visitor needs help with, a message to sales, a note on a partner application.

```tsx
import { TextArea } from "@commenda/meridian/ui/textarea";
import type { ReactNode } from "react";

function Fields({ children, cols = 2 }: { children: ReactNode; cols?: 2 | 3 }) {
	return (
		<div
			className={`not-prose my-4 grid gap-6 rounded-xl border border-fd-border bg-white p-8 ${
				cols === 3 ? "md:grid-cols-3" : "md:grid-cols-2"
			}`}
		>
			{children}
		</div>
	);
}

const HELP =
	"We sell in 30 US states and just crossed nexus in Texas. We need help registering and filing.";

export function TextareaField() {
	return (
		<Fields>
			<TextArea
				label="How can we help?"
				placeholder="e.g. We sell in 30 US states and need to register for sales tax"
			/>
			<TextArea
				label="How can we help?"
				defaultValue={HELP}
				description="A few lines help us bring the right expert to the call."
			/>
		</Fields>
	);
}
```

## Count and resize [#count-and-resize]

A count when there is a limit. Past it the field turns invalid and says by how much. The resize handle is optional and vertical only.

```tsx
import { TextArea } from "@commenda/meridian/ui/textarea";
import type { ReactNode } from "react";

function Fields({ children, cols = 2 }: { children: ReactNode; cols?: 2 | 3 }) {
	return (
		<div
			className={`not-prose my-4 grid gap-6 rounded-xl border border-fd-border bg-white p-8 ${
				cols === 3 ? "md:grid-cols-3" : "md:grid-cols-2"
			}`}
		>
			{children}
		</div>
	);
}

const HELP =
	"We sell in 30 US states and just crossed nexus in Texas. We need help registering and filing.";

export function TextareaCountResize() {
	return (
		<Fields>
			<TextArea
				label="How can we help?"
				defaultValue={HELP}
				description="A few lines help us bring the right expert to the call."
				characterLimitConfig={{ max: 500 }}
			/>
			<TextArea label="How can we help?" defaultValue={HELP} resizeConfig={{ mode: "manual" }} />
		</Fields>
	);
}
```

## States [#states]

The same states as Input. Invalid replaces the description with the error.

```tsx
import { TextArea } from "@commenda/meridian/ui/textarea";
import type { ReactNode } from "react";

function Fields({ children, cols = 2 }: { children: ReactNode; cols?: 2 | 3 }) {
	return (
		<div
			className={`not-prose my-4 grid gap-6 rounded-xl border border-fd-border bg-white p-8 ${
				cols === 3 ? "md:grid-cols-3" : "md:grid-cols-2"
			}`}
		>
			{children}
		</div>
	);
}

/** A form demo with its state name above it, full width so the field keeps its size. */
function Captioned({ label, children }: { label: string; children: ReactNode }) {
	return (
		<div className="flex min-w-0 flex-col gap-2">
			<span className="text-[12px] text-fd-muted-foreground">{label}</span>
			{children}
		</div>
	);
}

const HELP =
	"We sell in 30 US states and just crossed nexus in Texas. We need help registering and filing.";

export function TextareaStates() {
	return (
		<Fields cols={3}>
			<Captioned label="default">
				<TextArea
					label="How can we help?"
					placeholder="e.g. We sell in 30 US states and need to register for sales tax"
				/>
			</Captioned>
			<Captioned label="disabled">
				<TextArea
					label="How can we help?"
					defaultValue={HELP}
					disableConfig={{ isDisabled: true }}
				/>
			</Captioned>
			<Captioned label="invalid">
				<TextArea
					label="How can we help?"
					defaultValue="Sales tax help"
					errorConfig={{
						message: "Tell us a little more, at least 20 characters.",
						reveal: "immediate",
					}}
				/>
			</Captioned>
		</Fields>
	);
}
```

## Anatomy [#anatomy]

Label row, field, then a bottom row with the description or error on the left and the count on the right. The field starts at 80 and grows.

| Part | Value |
| --- | --- |
| Field | 80 minimum, radius 8, 1px soft-pearl 400 |
| Label | Label/14 Strong |
| Value | 16 |
| Description, error, count | 14 |

## API reference [#api-reference]

| Prop | Type | Description |
| --- | --- | --- |
| `label` (conditional) | `string` |  |
| `hideLabel` | `boolean` |  |
| `aria-label` (conditional) | `string` |  |
| `required` (conditional) | `true \| false` |  |
| `labelConfig` | `{ optionalLabel: string; help?: never; } \| { help: string; optionalLabel?: never; }` |  |
| `sourceConfig` | `FieldSourceConfig` |  |
| `description` | `string` |  |
| `errorConfig` | `{ message: string; reveal?: "after-blur" \| "immediate"; }` |  |
| `disableConfig` | `DisableConfig` |  |
| `value` (conditional) | `string` |  |
| `onValueChange` (conditional) | `(value: string) => void` |  |
| `defaultValue` | `string` |  |
| `variant` | `"plain" \| "default"` | Plain appearance is for embedding in a composite control such as Thread. |
| `resizeConfig` | `{ mode: "auto"; minHeight?: number; maxHeight: number; } \| { mode: "manual"; minHeight?: number; maxHeight?: number; } \| { mode: "fixed"; height: number; }` |  |
| `actionConfig` | `CopyAction` |  |
| `characterLimitConfig` (conditional) | `{ max: number; }` |  |
| `maxLength` | `number` |  |

**`labelConfig` fields, option 1 of 2**

| Field | Type | Description |
| --- | --- | --- |
| `optionalLabel` (required) | `string` |  |

Do not supply: `help`.

**`labelConfig` fields, option 2 of 2**

| Field | Type | Description |
| --- | --- | --- |
| `help` (required) | `string` |  |

Do not supply: `optionalLabel`.

**`sourceConfig` fields**

| Field | Type | Description |
| --- | --- | --- |
| `kind` (required) | `"entity" \| "record" \| "document"` |  |
| `label` (required) | `string` |  |
| `preview` (required) | `ReactNode` |  |
| `onOpen` (required) | `() => void` |  |
| `side` | `"top" \| "bottom"` |  |

**`errorConfig` fields**

| Field | Type | Description |
| --- | --- | --- |
| `message` (required) | `string` |  |
| `reveal` | `"after-blur" \| "immediate"` |  |

**`disableConfig` fields**

| Field | Type | Description |
| --- | --- | --- |
| `isDisabled` (required) | `boolean` |  |
| `reason` | `string` |  |

**`resizeConfig` fields, option 1 of 3**

| Field | Type | Description |
| --- | --- | --- |
| `mode` (required) | `"auto"` |  |
| `minHeight` | `number` |  |
| `maxHeight` (required) | `number` |  |

**`resizeConfig` fields, option 2 of 3**

| Field | Type | Description |
| --- | --- | --- |
| `mode` (required) | `"manual"` |  |
| `minHeight` | `number` |  |
| `maxHeight` | `number` |  |

**`resizeConfig` fields, option 3 of 3**

| Field | Type | Description |
| --- | --- | --- |
| `mode` (required) | `"fixed"` |  |
| `height` (required) | `number` |  |

**`actionConfig` fields**

| Field | Type | Description |
| --- | --- | --- |
| `kind` (required) | `"copy"` |  |
| `label` | `string` |  |
| `onCopy` | `() => void` |  |
| `onCopyError` | `(error: Error) => void` |  |

**`characterLimitConfig` fields**

| Field | Type | Description |
| --- | --- | --- |
| `max` (required) | `number` |  |

## Best practices [#best-practices]

- Use it for messages and notes that may run to two sentences or more. A single value is an Input.
- A textarea with a send button is a chat composer, not a Textarea.
- The placeholder is an example that starts with "e.g.", or nothing.
- Show a count only when there is a limit. Past the limit, the error says by how much.
- Let it grow with the text up to a maximum, then scroll. Turn the resize handle off when it grows on its own in a fixed layout.
- Keep it optional on demo forms. A required essay box costs leads.
- Source: Pathfinder Textarea. Meridian sets the value in 16px, the label in 14 and help and error text in 14.
