Forms
Textarea
Multiline field, 14 Regular at 140% line height, minimum 96px tall.
react-aria-components
Preview
"use client";
import { Textarea } from "@/components/ui/textarea";
export default function Example() {
return <Textarea label="Note" placeholder="Add a note…" className="w-full max-w-96" />;
}Installation
Components are copied into your project — no runtime package.
Install the following dependencies:
terminalnpm install react-aria-componentsCreate a
textarea.tsxfile and paste the following code into it.src/components/ui/textarea.tsx"use client"; import { TextArea as AriaTextArea, TextField, type TextFieldProps } from "react-aria-components"; import { cx } from "@/utils/cx"; import { Description, ErrorMessage, Label, fieldBase } from "./field"; export interface TextareaProps extends Omit<TextFieldProps, "className" | "children"> { label?: string; description?: string; errorMessage?: string; placeholder?: string; rows?: number; className?: string; } /** Multiline field — 14 Regular at 140% line height, min height 96. */ export function Textarea({ label, description, errorMessage, placeholder, rows = 4, className, ...props }: TextareaProps) { return ( <TextField {...props} isInvalid={props.isInvalid ?? Boolean(errorMessage)} className={cx("flex flex-col gap-2", className)}> {label && <Label>{label}</Label>} <AriaTextArea placeholder={placeholder} rows={rows} className={cx(fieldBase, "min-h-24 resize-y px-3 py-2.5 leading-[1.4]")} /> {description && !errorMessage && <Description>{description}</Description>} <ErrorMessage>{errorMessage}</ErrorMessage> </TextField> ); }Create a
field.tsxfile and paste the following code into it.src/components/ui/field.tsx"use client"; import type { ReactNode } from "react"; import { FieldError, Label as AriaLabel, Text } from "react-aria-components"; import { cx } from "@/utils/cx"; /** Shared field chrome: 40px tall, radius 12, 1px border-strong, accent border + 3px ring on focus. */ export const fieldBase = "w-full rounded-md border border-line-strong bg-surface text-base text-fg outline-none transition-[border,box-shadow] " + "placeholder:text-fg-muted data-hovered:border-fg-disabled " + "data-focused:border-accent data-focused:shadow-focus data-focus-within:border-accent data-focus-within:shadow-focus " + "data-invalid:border-error data-invalid:data-focused:shadow-focus-error " + "data-disabled:border-line data-disabled:bg-subtle data-disabled:text-fg-disabled data-disabled:placeholder:text-fg-disabled"; export function Label({ className, children }: { className?: string; children: ReactNode }) { return <AriaLabel className={cx("text-sm font-medium text-fg", className)}>{children}</AriaLabel>; } export function Description({ children }: { children: ReactNode }) { return ( <Text slot="description" className="text-sm text-fg-muted"> {children} </Text> ); } export function ErrorMessage({ children }: { children?: ReactNode }) { return <FieldError className="text-sm text-error-text">{children}</FieldError>; }Add the theme tokens and the
cxhelper from Installation if you haven’t yet, then update the import paths to match your project setup.