Textarea
Multi-line text for messages and notes.
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.
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
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
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.
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
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.
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
The same states as Input. Invalid replaces the description with the error.
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
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
| Prop | Type | Description |
|---|---|---|
labelConditional | string | From Pathfinder. |
hideLabel | boolean | From Pathfinder. |
aria-labelConditional | string | From Pathfinder. |
requiredConditional | true | false | From Pathfinder. |
labelConfig | ObjectView fields · 2 shapes | From Pathfinder. |
sourceConfig | FieldSourceConfigView fields | From Pathfinder. |
description | string | From Pathfinder. |
errorConfig | ObjectView fields | From Pathfinder. |
disableConfig | DisableConfigView fields | From Pathfinder. |
valueConditional | string | From Pathfinder. |
onValueChangeConditional | (value: string) => void | From Pathfinder. |
defaultValue | string | From Pathfinder. |
variant | "plain" | "default" | Plain appearance is for embedding in a composite control such as Thread. |
resizeConfig | ObjectView fields · 3 shapes | From Pathfinder. |
actionConfig | CopyActionView fields | From Pathfinder. |
characterLimitConfigConditional | ObjectView fields | From Pathfinder. |
maxLength | number | From Pathfinder. |
labelConfigObject fields
Choose one of these 2 shapes. Don't combine fields the chosen shape excludes.
Option 1
| Field | Type | Description |
|---|---|---|
optionalLabelRequired | string |
Do not supply: help.
Option 2
| Field | Type | Description |
|---|---|---|
helpRequired | string |
Do not supply: optionalLabel.
sourceConfigObject fields
| Field | Type | Description |
|---|---|---|
kindRequired | "entity" | "record" | "document" | |
labelRequired | string | |
previewRequired | ReactNode | |
onOpenRequired | () => void | |
side | "top" | "bottom" |
errorConfigObject fields
| Field | Type | Description |
|---|---|---|
messageRequired | string | |
reveal | "after-blur" | "immediate" |
disableConfigObject fields
| Field | Type | Description |
|---|---|---|
isDisabledRequired | boolean | |
reason | string |
resizeConfigObject fields
Choose one of these 3 shapes. Don't combine fields the chosen shape excludes.
Option 1
| Field | Type | Description |
|---|---|---|
modeRequired | "auto" | |
minHeight | number | |
maxHeightRequired | number |
Option 2
| Field | Type | Description |
|---|---|---|
modeRequired | "manual" | |
minHeight | number | |
maxHeight | number |
Option 3
| Field | Type | Description |
|---|---|---|
modeRequired | "fixed" | |
heightRequired | number |
actionConfigObject fields
| Field | Type | Description |
|---|---|---|
kindRequired | "copy" | |
label | string | |
onCopy | () => void | |
onCopyError | (error: Error) => void |
characterLimitConfigObject fields
| Field | Type | Description |
|---|---|---|
maxRequired | number |
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.