PrimeUI PRO for React is now available 🚀View Demos

Textarea

An unstyled multi-line text input component with auto-resize support.

Build fully custom multi-line text inputs with complete control over layout and styling.

basic-demo

Pre-styled Versions

Choose a pre-styled library to use Textarea with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Single component rendering a native <textarea> element
  • Built-in auto-resize that adjusts height based on content using CSS field-sizing with JavaScript fallback
  • Native <textarea> semantics with full HTML attribute support

Usage#

import { Textarea } from 'primereact/textarea';
<Textarea rows={5} cols={30} />

Behavior#

Polymorphic Rendering#

Use as to change the rendered HTML element or use a custom React component.

<Textarea as="div" contentEditable role="textbox" />

Render Function Children#

Textarea accepts a render function as children, providing access to the component instance.

<Textarea>{(instance) => <span>Custom render</span>}</Textarea>

Pass Through#

The component's PT demo referenced as textarea-pt is unavailable or does not exist.

API#

Textarea#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TextareaInstance) => undefined | CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TextareaInstance) => undefined | string)—
The class name to apply to the component.
asnull | string | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTextareaInstance—
The instance to pass to the component.
ptSafeRecord<TextareaPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TextareaInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
autoResizebooleanfalse
When present, height of textarea changes as being typed.
invalidbooleanfalse
When present, it marks the textarea as invalid.
size"small" | "large"—
Defines the size of the Textarea.
variant"outlined" | "filled"—
Specifies the input variant of the component.
fluidboolean—
When enabled, the component will stretch to occupy the full width of its container.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"textarea"
data-part"root"
data-invalidPresent when invalid

Defines passthrough(pt) options of Textarea component.

labeltypedescription
rootTextareaPassThroughType<TextareaHTMLAttributes<HTMLTextAreaElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

Textarea renders a native textarea element. Provide an accessible name with a visible label, aria-label, or aria-labelledby.

Keyboard Support#

Textarea uses native textarea keyboard behavior.