Skip to content

Textarea

A multiline text input with three sizes that integrates with Field.

Helps the agent decide when to search it.

hero.tsx

Usage guidelines

  • Use Textarea for free text that spans several lines, such as descriptions, prompts and notes. A single line of text uses Input.
  • Put the textarea in a Field with a FieldLabel, and add FieldDescription and FieldError where they help. Do not use placeholder as the label.
  • Match size to the surrounding controls. medium is the default.
  • The textarea keeps a minimum height; set rows only for a taller starting height. Content past the height scrolls.
  • Control the value with both value and onValueChange; otherwise pass defaultValue. onValueChange receives the string value, not the change event.
  • Textarea renders no character counter. maxLength limits the input natively. State the limit in the FieldDescription, 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: Form or a native <form>, with a Button of type="submit".

Anatomy

tsx
tsx

Examples

Sizes

small, medium and large set the padding, radius and text size together.

sizes.tsx

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.

Use at least 20 characters.
states.tsx

Validation in a form

required and minLength drive the matching FieldError messages. Submit the empty form to see them.

Shown to teammates when they choose a knowledge source.

validation.tsx

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/500
auto-height.tsx

API 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.

Base UI Field.Control docs

Props
PropTypeDefaultDetails
valueTextareaValueNo default
defaultValueTextareaValueNo default
onValueChange(value: string, eventDetails: TextareaChangeEventDetails) => voidNo default
size'large' | 'medium' | 'small''medium'
childrenundefinedNo default
Base UI Field.Control docs

Valid prop combinations:

  • value: string | number, defaultValue?: undefined, onValueChange: (value: string, eventDetails: TextareaChangeEventDetails) => void
  • value?: undefined, defaultValue?: TextareaValue, onValueChange?: (value: string, eventDetails: TextareaChangeEventDetails) => void
Data attributes
AttributeDescription
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.