Marigold
Getting StartedFoundationsComponentsPatternsReleases
Discover new Tutorials!

Components

Overview

Application

MarigoldProvider
RouterProvider

Layout

Aside
Aspect
Breakout
Center
Columns
Container
Grid
Inline
updated
Inset
Scrollable
Split
Stack
Tiles

Form

Autocomplete
updated
Button
updated
Calendar
Checkbox
updated
ComboBox
updated
DateField
DatePicker
Form
Multiselect
NumberField
Radio
updated
SearchField
Select
Slider
updated
Switch
TextArea
updated
TextField
TimeField

Collection

SelectList
Table
updated
Tag

Navigation

Accordion
Breadcrumbs
beta
Pagination
Tabs

Overlay

ContextualHelp
Dialog
Menu
Toast
beta
Tooltip

Content

Badge
Card
Divider
Headline
Icon
Link
List
SectionMessage
SVG
Text
VisuallyHidden
XLoader

Formatters

DateFormat
updated
NumericFormat
updated

Hooks and Utils

cn
cva
extendTheme
useAsyncListData
useListData
useResponsiveValue
useTheme

TextArea

Component for entering multiline text input.

The <TextArea> is a form component that allows users to enter and edit multiline text content with a keyboard. It consists of a textarea input field, a label, and optional help text that can also display error messages for validation feedback.

It behaves similarly to the <TextField> component but is designed specifically for longer, multiline text input. The properties have identical behavior to those in <TextField>.

You can also add all usual properties from the HTML textarea element.

Anatomy

A textarea consists of an input area that accepts multiline text, and a label which informs the user about the content they need to enter. <TextArea> automatically manages the relationship between these elements and supports optional description and error message elements for providing context and validation feedback.

Appearance

The appearance of a component can be customized using the variant and size props. These props adjust the visual style and dimensions of the component, available values are based on the active theme.

Variant
Size
The selected theme does not has any options for "variant" and "size".
PropertyTypeDescription
variant-The available variants of this component.
size-The available sizes of this component.

Usage

Use a <TextArea> when users need to input longer text content that spans multiple lines, such as comments, descriptions, feedback, or any free-form text that cannot be effectively captured in a single-line text field.

The <TextArea> is ideal for content like product descriptions, user reviews, messages, notes, or any scenario where users might need to write several sentences or paragraphs. It provides enough space for users to compose and review their text before submission.

When to use TextArea vs TextField

Choose <TextArea> over <TextField> when you expect users to enter more than a few words or when the content naturally spans multiple lines. Use <TextField> for single-line inputs like names, emails, or short responses.

Do

Use TextArea for longer text content like comments, descriptions, or feedback that spans multiple lines.

Don't

Don't use TextArea for short, single-line inputs like names or email addresses.

Labels and placeholders

Keep labels short and descriptive. The label should clearly indicate what type of content is expected. Avoid using placeholder text as a replacement for labels, as it disappears when users start typing and can cause accessibility issues.

Do

Use clear, concise labels that describe the expected content.

Don't

Don't rely on placeholder text as the primary way to indicate what content is expected.

Sizing and rows

Set an appropriate initial height using the rows prop to give users a visual hint about how much content is expected. For short responses, 3-4 rows is usually sufficient. For longer content like detailed feedback or descriptions, consider 6-8 rows or more.

Do

Set an appropriate number of rows that matches the expected content length.

Don't

Don't use too few rows for content that typically requires more space, as it creates a poor user experience.

Props

Did you know? You can explore, test, and customize props live in Marigold's storybook. Watch the effects they have in real-time!
View TextArea stories
aria-activedescendant?
string;
Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.
aria-autocomplete?
"none" | "inline" | "list" | "both";
Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be presented if they are made.
aria-controls?
string;
Identifies the element (or elements) whose contents or presence are controlled by the current element.
aria-describedby?
string;
Identifies the element (or elements) that describes the object.
aria-details?
string;
Identifies the element (or elements) that provide a detailed, extended description for the object.
aria-errormessage?
string;
Identifies the element that provides an error message for the object.
aria-haspopup?
boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog";
Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
aria-label?
string;
Defines a string value that labels the current element.
aria-labelledby?
string;
Identifies the element (or elements) that labels the current element.
autoComplete?
string;
Describes the type of autocomplete functionality the input should provide if any. See MDN.
autoCorrect?
string;
An attribute that takes as its value a space-separated string that describes what, if any, type of autocomplete functionality the input should provide. See MDN.
autoFocus?
boolean;
Whether the element should receive focus on render.
defaultValue?
string;
The default value of the textarea.
Defaults to:
"none"
description?
ReactNode;
A helpful text.
dir?
string;
disabled?
boolean;
If true, the textarea is disabled.
Defaults to:
"false"
enterKeyHint?
"enter" | "done" | "go" | "next" | "previous" | "search" | "send";
An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See MDN.
error?
boolean;
If true, the field is considered invalid and if set the errorMessage is shown instead of the description.
Defaults to:
"false"
errorMessage?
ReactNode | ((v: ValidationResult) => ReactNode);
An error message.
excludeFromTabOrder?
boolean;
Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available.
form?
string;
The <form> element to associate the input with. The value of this attribute must be the id of a <form> in the same document. See MDN.
hidden?
boolean;
id?
string;
The element's unique identifier. See MDN.
inert?
boolean;
inputMode?
"none" | "search" | "text" | "url" | "tel" | "email" | "numeric" | "decimal";
Hints at the type of data that might be entered by the user while editing the element or its contents. See MDN.
label?
ReactNode;
Specifies the label of the field.
lang?
string;
maxLength?
number;
The maximum number of characters supported by the input. See MDN.
minLength?
number;
The minimum number of characters required by the input. See MDN.
name?
string;
The name of the input element, used when submitting an HTML form. See MDN.
onAnimationEnd?
AnimationEventHandler<HTMLDivElement>;
onAnimationEndCapture?
AnimationEventHandler<HTMLDivElement>;
onAnimationIteration?
AnimationEventHandler<HTMLDivElement>;
onAnimationIterationCapture?
AnimationEventHandler<HTMLDivElement>;
onAnimationStart?
AnimationEventHandler<HTMLDivElement>;
onAnimationStartCapture?
AnimationEventHandler<HTMLDivElement>;
onAuxClick?
MouseEventHandler<HTMLDivElement>;
onAuxClickCapture?
MouseEventHandler<HTMLDivElement>;
onBeforeInput?
FormEventHandler<HTMLInputElement>;
Handler that is called when the input value is about to be modified. See MDN.
onBlur?
(e: FocusEvent<HTMLInputElement, Element>) => void;
Handler that is called when the element loses focus.
onChange?
(value: string) => void;
Handler that is called when the value changes.
onClick?
MouseEventHandler<HTMLDivElement>;
onClickCapture?
MouseEventHandler<HTMLDivElement>;
onCompositionEnd?
CompositionEventHandler<HTMLInputElement>;
Handler that is called when a text composition system completes or cancels the current text composition session. See MDN.
onCompositionStart?
CompositionEventHandler<HTMLInputElement>;
Handler that is called when a text composition system starts a new text composition session. See MDN.
onCompositionUpdate?
CompositionEventHandler<HTMLInputElement>;
Handler that is called when a new character is received in the current text composition session. See MDN.
onContextMenu?
MouseEventHandler<HTMLDivElement>;
onContextMenuCapture?
MouseEventHandler<HTMLDivElement>;
onCopy?
ClipboardEventHandler<HTMLInputElement>;
Handler that is called when the user copies text. See MDN.
onCut?
ClipboardEventHandler<HTMLInputElement>;
Handler that is called when the user cuts text. See MDN.
onDoubleClick?
MouseEventHandler<HTMLDivElement>;
onDoubleClickCapture?
MouseEventHandler<HTMLDivElement>;
onFocus?
(e: FocusEvent<HTMLInputElement, Element>) => void;
Handler that is called when the element receives focus.
onFocusChange?
(isFocused: boolean) => void;
Handler that is called when the element's focus status changes.
onGotPointerCapture?
PointerEventHandler<HTMLDivElement>;
onGotPointerCaptureCapture?
PointerEventHandler<HTMLDivElement>;
onInput?
FormEventHandler<HTMLInputElement>;
Handler that is called when the input value is modified. See MDN.
onKeyDown?
(e: KeyboardEvent) => void;
Handler that is called when a key is pressed.
onKeyUp?
(e: KeyboardEvent) => void;
Handler that is called when a key is released.
onLostPointerCapture?
PointerEventHandler<HTMLDivElement>;
onLostPointerCaptureCapture?
PointerEventHandler<HTMLDivElement>;
onMouseDown?
MouseEventHandler<HTMLDivElement>;
onMouseDownCapture?
MouseEventHandler<HTMLDivElement>;
onMouseEnter?
MouseEventHandler<HTMLDivElement>;
onMouseLeave?
MouseEventHandler<HTMLDivElement>;
onMouseMove?
MouseEventHandler<HTMLDivElement>;
onMouseMoveCapture?
MouseEventHandler<HTMLDivElement>;
onMouseOut?
MouseEventHandler<HTMLDivElement>;
onMouseOutCapture?
MouseEventHandler<HTMLDivElement>;
onMouseOver?
MouseEventHandler<HTMLDivElement>;
onMouseOverCapture?
MouseEventHandler<HTMLDivElement>;
onMouseUp?
MouseEventHandler<HTMLDivElement>;
onMouseUpCapture?
MouseEventHandler<HTMLDivElement>;
onPaste?
ClipboardEventHandler<HTMLInputElement>;
Handler that is called when the user pastes text. See MDN.
onPointerCancel?
PointerEventHandler<HTMLDivElement>;
onPointerCancelCapture?
PointerEventHandler<HTMLDivElement>;
onPointerDown?
PointerEventHandler<HTMLDivElement>;
onPointerDownCapture?
PointerEventHandler<HTMLDivElement>;
onPointerEnter?
PointerEventHandler<HTMLDivElement>;
onPointerLeave?
PointerEventHandler<HTMLDivElement>;
onPointerMove?
PointerEventHandler<HTMLDivElement>;
onPointerMoveCapture?
PointerEventHandler<HTMLDivElement>;
onPointerOut?
PointerEventHandler<HTMLDivElement>;
onPointerOutCapture?
PointerEventHandler<HTMLDivElement>;
onPointerOver?
PointerEventHandler<HTMLDivElement>;
onPointerOverCapture?
PointerEventHandler<HTMLDivElement>;
onPointerUp?
PointerEventHandler<HTMLDivElement>;
onPointerUpCapture?
PointerEventHandler<HTMLDivElement>;
onScroll?
UIEventHandler<HTMLDivElement>;
onScrollCapture?
UIEventHandler<HTMLDivElement>;
onSelect?
ReactEventHandler<HTMLInputElement>;
Handler that is called when text in the input is selected. See MDN.
onTouchCancel?
TouchEventHandler<HTMLDivElement>;
onTouchCancelCapture?
TouchEventHandler<HTMLDivElement>;
onTouchEnd?
TouchEventHandler<HTMLDivElement>;
onTouchEndCapture?
TouchEventHandler<HTMLDivElement>;
onTouchMove?
TouchEventHandler<HTMLDivElement>;
onTouchMoveCapture?
TouchEventHandler<HTMLDivElement>;
onTouchStart?
TouchEventHandler<HTMLDivElement>;
onTouchStartCapture?
TouchEventHandler<HTMLDivElement>;
onTransitionCancel?
TransitionEventHandler<HTMLDivElement>;
onTransitionCancelCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionEnd?
TransitionEventHandler<HTMLDivElement>;
onTransitionEndCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionRun?
TransitionEventHandler<HTMLDivElement>;
onTransitionRunCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionStart?
TransitionEventHandler<HTMLDivElement>;
onTransitionStartCapture?
TransitionEventHandler<HTMLDivElement>;
onWheel?
WheelEventHandler<HTMLDivElement>;
onWheelCapture?
WheelEventHandler<HTMLDivElement>;
pattern?
string;
Regex pattern that the value of the input must match to be valid. See MDN.
placeholder?
string;
Placeholder text for the textarea.
Defaults to:
"none"
readOnly?
boolean;
If true, the textarea is read-only.
Defaults to:
"false"
ref?
Ref<HTMLTextAreaElement>;
Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref). @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
required?
boolean;
If true, the textarea is required.
Defaults to:
"false"
rows?
number;
Sets the number of rows in the textarea.
Defaults to:
"none"
slot?
string | null;
A slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.
spellCheck?
string;
An enumerated attribute that defines whether the element may be checked for spelling errors. See MDN.
translate?
"yes" | "no";
type?
"search" | "text" | "url" | "tel" | "email" | "password" | (string & {});
The type of input to render. See MDN.
validate?
(value: string) => true | ValidationError | null;
A function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if validationBehavior="native". For realtime validation, use the isInvalid prop instead.
validationBehavior?
"native" | "aria";
Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.
Defaults to:
'native'
value?
string;
The value of the textarea.
Defaults to:
"none"
width?
WidthProp;
Sets the width of the field. You can see allowed tokens here: https://tailwindcss.com/docs/width
Defaults to:
"full"
Last update: 8 minutes ago
Build with 🥵, 🧡 and
v15.0.0