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:
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:
Interactive comments
Auto-resizing with character counter:
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.
Prop | Type | Default | Description |
---|---|---|---|
placeholder | string | - | Placeholder text when empty |
value | string | - | Controlled value of the textarea |
defaultValue | string | - | Uncontrolled default value |
onChange | (event) => void | - | Change event handler |
disabled | boolean | false | Disables the textarea |
readOnly | boolean | false | Makes textarea read-only |
required | boolean | false | Makes field required in forms |
rows | number | - | Visible text lines |
cols | number | - | Visible width in characters |
maxLength | number | - | Maximum character length |
minLength | number | - | Minimum character length |
wrap | "hard" | "soft" | "off" | "soft" | How text wraps |
className | string | - | Additional CSS classes |
Resize Behavior
Control how users can resize the textarea:
Class | CSS Property | Description |
---|---|---|
resize-none | resize: none | Prevents resizing (default) |
resize | resize: both | Allows horizontal and vertical |
resize-y | resize: vertical | Vertical resizing only |
resize-x | resize: horizontal | Horizontal resizing only |
Common Patterns
Basic textarea with helper text
Form integration with validation
Auto-resize with character counter
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
Tabs
A set of layered sections of content—known as tab panels—that are displayed one at a time. Perfect for organizing complex interfaces in React applications with Next.js, TypeScript, and Tailwind CSS.
Toggle
A two-state button that can be either on or off. Perfect for binary options, formatting controls, and feature toggles in React applications with Next.js, TypeScript, and Tailwind CSS.