Text Area
⋯
Textarea renders a native multiline control with the 80px minimum height, 8px radius, and
Default, Focused, Filled, Error, and Disabled treatments in the Input design.
import { Textarea } from "@nesra/ui/textarea";
export function MessageField() { return <Textarea label="Message" name="message" placeholder="Type your message here" required />;}Textarea is also exported from @nesra/ui.
Examples
Section titled “Examples”States
Section titled “States”error adds the destructive border and ring, which stay while the textarea has focus. Colors follow
the field state colors in Light and Dark.
import { Textarea } from "@nesra/ui/textarea";
export function TextareaBasicExample() { return ( <div className="grid w-full max-w-xl gap-nesra-spacing-lg"> <Textarea label="Message" name="message" placeholder="Type your message here" description="This is a hint text to help user" required /> <Textarea label="Filled" defaultValue="I would like to learn more about Nesra UI." /> <Textarea label="Error" error="This field contains validation errors" /> <Textarea label="Disabled" placeholder="Type your message here" disabled /> </div> );}Controlled value and character limit
Section titled “Controlled value and character limit”Textarea forwards native value, onChange, and maxLength props. The counter belongs to the page.
import { Textarea } from "@nesra/ui/textarea";import { useState } from "react";
const limit = 160;
export function TextareaControlledExample() { const [message, setMessage] = useState("");
return ( <div className="grid w-full max-w-xl gap-nesra-spacing-sm"> <Textarea label="Short message" name="message" maxLength={limit} placeholder="Tell us what you need" value={message} onChange={(event) => setMessage(event.currentTarget.value)} /> <output className="type-nesra-body-small-regular text-nesra-text-support"> {message.length} / {limit} characters </output> </div> );}Native form submission
Section titled “Native form submission”name and required work with a regular form. The textarea can be resized vertically.
import { Textarea } from "@nesra/ui/textarea";import { useState, type SubmitEvent } from "react";
export function TextareaFormExample() { const [submitted, setSubmitted] = useState("");
function handleSubmit(event: SubmitEvent<HTMLFormElement>) { event.preventDefault(); setSubmitted(String(new FormData(event.currentTarget).get("feedback") ?? "")); }
return ( <form className="grid w-full max-w-xl gap-nesra-spacing-md" onSubmit={handleSubmit}> <Textarea description="Share one improvement you would like to see." label="Feedback" name="feedback" required /> <button className="w-fit rounded-nesra-sm border border-nesra-stroke-border px-nesra-padding-xl py-nesra-padding-sm" type="submit" > Send feedback </button> <output className="type-nesra-body-small-regular text-nesra-text-support"> {submitted ? `Submitted: ${submitted}` : "Your message will appear here after submission."} </output> </form> );}Accessibility
Section titled “Accessibility”labelassociates visible text with the native textarea. Give a bareTextareaan accessible name.descriptionanderrorprovide associated text. The form decides when to seterror.- The forwarded ref points to the textarea. Native
name,required,disabled,value, anddefaultValuework as on a regular textarea.
API reference
Section titled “API reference”Textarea
Section titled “Textarea”| Prop | Type | Default | Effect |
|---|---|---|---|
label |
ReactNode |
— | Adds a visible Base UI Field label. |
description |
ReactNode |
— | Adds help text below the textarea. |
error |
FieldError |
— | Displays an associated validation message. |
Textarea also accepts native textarea props, including name, required, disabled, value,
defaultValue, onChange, and maxLength. Its ref points to the native textarea. See the
FieldError type for validation matching.
The visual values come from the color roles, typography roles, layout scale, and shape and elevation tokens.