Join our Discord Community

Textarea

Captures multi-line user input for forms, comments, and longer text content. Perfect for feedback forms and messaging in React applications with Next.js, TypeScript, and Tailwind CSS.

You know those tiny input fields that make you write a novel in a single line? Textareas give users room to breathe when they need to write more than a quick response - comments, feedback, descriptions, messages - anywhere you need actual paragraphs instead of cramped single lines.

Basic textarea with label

Simple multi-line input with helper text:

Loading component...

Clean textarea with proper labeling and helper text. This free open source React component extends the native textarea with consistent styling and full accessibility support.

npx shadcn@latest add textarea

Why textareas matter for user input

Regular inputs work for names and emails, but textareas handle real communication:

  • Natural writing - Users can see multiple lines while typing
  • Better context - Entire message visible without scrolling horizontally
  • Edit friendly - Easy to review and revise before submitting
  • Mobile optimized - Soft keyboards work better with vertical space
  • Character awareness - Users can gauge message length visually
  • Formatting preservation - Line breaks and paragraphs stay intact

Real-world textarea patterns

Form validation

Bio field with character limits:

Loading component...

Interactive comments

Auto-resizing with character counter:

Loading component...

These examples show textareas doing real work - form validation, comment systems, character counting. Each pattern solves specific user needs for longer text input.

Perfect for content input

Textareas shine when users need to express themselves properly. Support tickets, user feedback, comment sections, message composers, bio fields, product descriptions. Much better than forcing users to cram thoughts into single-line inputs.

Built on native HTML textarea element. Full TypeScript support. Styled with Tailwind CSS to match the shadcn design system.

API Reference

Textarea

Extends the native textarea element with consistent styling.

PropTypeDefaultDescription
placeholderstring-Placeholder text when empty
valuestring-Controlled value of the textarea
defaultValuestring-Uncontrolled default value
onChange(event) => void-Change event handler
disabledbooleanfalseDisables the textarea
readOnlybooleanfalseMakes textarea read-only
requiredbooleanfalseMakes field required in forms
rowsnumber-Visible text lines
colsnumber-Visible width in characters
maxLengthnumber-Maximum character length
minLengthnumber-Minimum character length
wrap"hard" | "soft" | "off""soft"How text wraps
classNamestring-Additional CSS classes

Resize Behavior

Control how users can resize the textarea:

ClassCSS PropertyDescription
resize-noneresize: nonePrevents resizing (default)
resizeresize: bothAllows horizontal and vertical
resize-yresize: verticalVertical resizing only
resize-xresize: horizontalHorizontal resizing only

Common Patterns

Basic textarea with helper text

Loading component...

Form integration with validation

Loading component...

Auto-resize with character counter

Loading component...

Form Integration

The textarea integrates seamlessly with React Hook Form and other form libraries. Check the form validation example above to see how validation, error messages, and character limits work together.

Accessibility Features

Built-in accessibility support includes:

  • Label association - Properly linked with Label components
  • ARIA attributes - Supports aria-label, aria-describedby
  • Keyboard navigation - Full keyboard support
  • Focus management - Clear focus indicators
  • Screen reader support - Announces character limits and validation
  • Error states - Accessible error messages with FormMessage
  • Required indication - Clear required field marking

Design tips for textareas

Keep these principles in mind when using textareas:

  • Size appropriately - Match height to expected content length
  • Show limits clearly - Display character counts before hitting limit
  • Provide examples - Placeholder text should guide users
  • Enable spell check - Unless handling code or technical content
  • Consider auto-save - For longer content that might be lost
  • Allow formatting - Consider rich text for complex content
  • Resize thoughtfully - Vertical resize usually makes most sense
  • Mobile test - Ensure comfortable typing on small screens
  • Preserve drafts - Don't lose user input on navigation
  • Clear submission - Show what happens after submit