Skip to content

Components / Textarea

Textarea

A native multiline field with square, monospaced styling. Write a message, keep its label visible, and use normal browser form behavior.

Storybook runs locally or as a separately hosted build. Resource links match the install revision.

Usage playground

Write a multiline message. Three rows and vertical resizing are the defaults; long content scrolls without automatically growing. The invalid state demonstrates presentation, not validation.

React / TSX
'use client';

import { useId, useState } from 'react';
import { Textarea } from '@/components/ui/yads-textarea';
import { Label } from '@/components/ui/yads-label';

Installation

pnpm dlx [email protected] add biehlio/yet-another-design-system/textarea#e7b31d0e0c9d8b24d53e97ca38b3b68d345e9f40

Documentation samples use basic Tailwind utilities for layout. Install each YADS component imported by the sample.

Run this revision-pinned command in a project configured for shadcn. It installs yads-textarea, its scoped CSS module and JetBrains Mono. The primitive needs no Tailwind, global theme or form library.

Import Textarea from @/components/ui/yads-textarea, adjusting the alias as needed. Samples compose separately installed YADS Label and Button, with basic Tailwind layout. Copy sample includes the complete module and any recipe CSS, even while collapsed. Interactive examples include a client boundary for React Server Component apps.

Helper text and errors

Compose Label, help and error text around the control. This application starts with an explicit error and checks native required validity as you type. Textarea does not decide when to show feedback.

Include the details we need to reply.

Write a message before continuing.

React / TSX
'use client';

import { useId, useState } from 'react';
import { Textarea } from '@/components/ui/yads-textarea';
import { Label } from '@/components/ui/yads-label';

Native form submission

Required uses browser validation. Enter inserts a newline; use the submit button to send. The additional field is outside the form but associated by its generated form ID. Reset restores both uncontrolled fields. This local demonstration sends no network request.

React / TSX
'use client';

import { useId, useState } from 'react';
import { Textarea } from '@/components/ui/yads-textarea';
import { Label } from '@/components/ui/yads-label';
import { Button } from '@/components/ui/yads-button';

className customization

Supply rows to change the initial height. The default is three rows; this field uses five. A repeated class selector overrides the scoped border and resize rules without removing theme colors or focus. Long content still scrolls; there is no autosize mode.

React / TSX
'use client';

import { useId } from 'react';
import { Textarea } from '@/components/ui/yads-textarea';
import { Label } from '@/components/ui/yads-label';

Accessibility

  • Give the field a visible name. Compose YADS Label with htmlFor matching a unique textarea id. Use useId when rendering repeated fields. A placeholder is not a label.
  • Explain requirements and errors. Mark required fields visibly and with required. Associate help/errors using aria-describedby and set aria-invalid when the application shows an error. Do not rely on color alone.
  • Keep native keyboard behavior. Enter inserts a newline. Tab moves to the next control, rather than inserting indentation. Preserve the visible focus ring. Disabled fields are skipped; read-only values stay selectable and included in submission.
  • Leave room to write. Three rows are the default, with vertical manual resizing. Long content scrolls internally. Consumers can supply more rows or override resize; do not require pointer resizing to make the field usable.
  • Keep ownership clear. Textarea generates no labels, help, counters or validation messages. Native required/length constraints and the application’s feedback policy are separate from explicit aria-invalid styling.

Standalone light colors are the default. A dark ancestor selects the scoped dark palette without a provider or site variables.

API reference

Import { Textarea, type TextareaProps } from @/components/ui/yads-textarea. TextareaProps is React.TextareaHTMLAttributes<HTMLTextAreaElement>. The component renders one native textarea and forwards its ref.

Focus the table and scroll horizontally on narrow screens.

Textarea props, types, defaults and behavior
PropTypeDefaultDescription
rowsnumber3Initial visible line count. Explicit rows is honored; there is no fixed CSS height or automatic growth.
id / namestringNot setAssociate an external Label with id; name includes the value in FormData.
value / onChangeNative value / ChangeEventHandler<HTMLTextAreaElement>Not setControlled usage: update value synchronously on change. Do not switch control modes.
defaultValueNative textarea valueNot setInitial uncontrolled value, restored by browser form reset. Do not combine with value.
disabledbooleanfalseNot editable, skipped by Tab and excluded from submission.
readOnlybooleanfalseSelectable, focusable and submitted, but not editable. Uses a dashed border.
required / minLength / maxLengthboolean / number / numberNot setNative constraints. Textarea does not create errors, counters or aria-invalid.
aria-invalidNative ARIA valueNot settrue styles the error border and focus ring; connect explanatory text with aria-describedby.
formstringNot setAssociates with a form ID, including when the textarea is outside that form.
cols / wrapnumber / "soft" | "hard" | "off"Browser defaultsNative wrapping and submission behavior. Width is 100% by default; use CSS to change it.
className / stylestring / CSSPropertiesNot setAdds classes or styles while retaining the scoped class. Resize is CSS, not a component prop.
refReact.Ref<HTMLTextAreaElement>Not setForwarded to the native textarea for focus, selection and native validity methods.

Native attributes and events

placeholder, autoComplete, inputMode, aria-*, data-*, event handlers and other native textarea props pass through. Browser form reset restores uncontrolled defaultValue; a controlled owner must update its own state on reset. No rich-text, autosize, validation or character-counter API is added.

Sizing and playground defaults

Rows defaults to three. Width is 100%, resize is vertical and overflow scrolls; CSS does not fix height. className or style can override resizing. Reset restores the editable controlled message “Tell us about your project.” followed by “Include any useful details.” on the next line. The state menu is a documentation control, not a Textarea prop.