Textarea
A multiline text input with three sizes that integrates with Field.
Helps the agent decide when to search it.
Usage guidelines
- Use
Textareafor free text that spans several lines, such as descriptions, prompts and notes. A single line of text usesInput. - Put the textarea in a
Fieldwith aFieldLabel, and addFieldDescriptionandFieldErrorwhere they help. Do not useplaceholderas the label. - Match
sizeto the surrounding controls.mediumis the default. - The textarea keeps a minimum height; set
rowsonly for a taller starting height. Content past the height scrolls. - Control the value with both
valueandonValueChange; otherwise passdefaultValue.onValueChangereceives the string value, not the change event. Textarearenders no character counter.maxLengthlimits the input natively. State the limit in theFieldDescription, and keep a visible count outside it so the count is not read with the description.- Textareas that save together belong in a real form boundary:
Formor a native<form>, with aButtonoftype="submit".
Anatomy
Examples
Sizes
small, medium and large set the padding, radius and text size together.
States
Set invalid on the Field when application code owns the validity, and render <FieldError match> while it is invalid; typing at least 20 characters clears the error. A read-only textarea stays focusable so its value can be selected and copied; a disabled one leaves the tab order and is not submitted.
Validation in a form
required and minLength drive the matching FieldError messages. Submit the empty form to see them.
Auto height and character count
The field-sizing-content utility lets the textarea grow with its content up to max-h-40, then scroll. Browsers without field-sizing keep the fixed height. The description states the limit that maxLength enforces; the running count sits next to it as plain text, outside the description, so screen readers do not read it with the description or announce it on every keystroke.
Sent before every conversation. Up to 500 characters.
62/500API reference
Textarea
A multiline text input that integrates with Field for labeling and validation. Renders a <textarea> element.
Controlled usage requires both value and onValueChange.
| Prop | Type | Default | Details |
|---|---|---|---|
value | TextareaValue | No default | |
defaultValue | TextareaValue | No default | |
onValueChange | (value: string, eventDetails: TextareaChangeEventDetails) => void | No default | |
size | 'large' | 'medium' | 'small' | 'medium' | |
children | undefined | No default | |
className | string | ((state: FieldControlState) => string | undefined) | No default | |
style | React.CSSProperties | ((state: FieldControlState) => React.CSSProperties | undefined) | No default | |
Valid prop combinations:
value: string | number,defaultValue?: undefined,onValueChange: (value: string, eventDetails: TextareaChangeEventDetails) => voidvalue?: undefined,defaultValue?: TextareaValue,onValueChange?: (value: string, eventDetails: TextareaChangeEventDetails) => void
| Attribute | Description |
|---|---|
data-disabled | Present when the field is disabled. |
data-valid | Present when the field is in a valid state. |
data-invalid | Present when the field is in an invalid state. |
data-touched | Present when the field has been touched. |
data-dirty | Present when the field's value has changed. |
data-filled | Present when the field is filled. |
data-focused | Present when the field control is focused. |