Skip to main content

Textarea

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The Textarea component provides a multi-line text input with consistent styling and accessibility features. Built with proper focus management and responsive design, it's perfect for comments, descriptions, messages, and any multi-line text input needs.

Basic Usage

With Label

Different Sizes

Small (3 rows)

Medium (5 rows)

Large (8 rows)

Controlled Textarea

Characters: 0/200200 remaining

Disabled State

Form Integration

Feedback Form

Auto-Resize Textarea

This textarea automatically adjusts its height based on content.

Properties

Textarea

PropertyTypeDescription
valuestringThe controlled value of the textarea.
defaultValuestringThe default value (uncontrolled).
onChange(event: ChangeEvent<HTMLTextAreaElement>) => voidCallback fired when the value changes.
placeholderstringPlaceholder text displayed when empty.
disabledbooleanWhether the textarea is disabled.
requiredbooleanWhether the textarea is required in forms.
readOnlybooleanWhether the textarea is read-only.
rowsnumberNumber of visible text lines.
colsnumberNumber of visible character columns.
maxLengthnumberMaximum number of characters allowed.
minLengthnumberMinimum number of characters required.
wrap"hard" | "soft" | "off"How text wrapping should be handled.
resize"none" | "both" | "horizontal" | "vertical"CSS resize property.
classNamestringAdditional CSS classes for the textarea.
idstringHTML id attribute.
namestringHTML name attribute for forms.
autoFocusbooleanWhether to focus the textarea on mount.
onFocus(event: FocusEvent<HTMLTextAreaElement>) => voidCallback fired when focused.
onBlur(event: FocusEvent<HTMLTextAreaElement>) => voidCallback fired when blurred.

Accessibility

The Textarea component includes comprehensive accessibility features:

  • Keyboard Navigation - Standard textarea keyboard interactions
  • Focus Management - Proper focus indicators and handling
  • Screen Reader Support - Works with assistive technologies
  • Label Association - Proper labeling with htmlFor/id attributes
  • Form Integration - Seamless integration with form libraries
  • ARIA Support - Can be enhanced with ARIA attributes
  • Validation States - Supports required, invalid, and other states

Common Use Cases

The Textarea component is perfect for:

  • Comments - User comments and feedback forms
  • Descriptions - Product descriptions and detailed information
  • Messages - Contact forms and messaging interfaces
  • Notes - User notes and documentation
  • Reviews - Product reviews and testimonials
  • Content Creation - Blog posts and article content
  • Code Input - Code snippets and configuration
  • Addresses - Multi-line address inputs

Best Practices

  1. Appropriate Sizing - Set reasonable default rows for content type
  2. Character Limits - Implement and display character count when needed
  3. Placeholder Text - Use helpful placeholder text to guide users
  4. Validation - Provide clear validation feedback for required fields
  5. Auto-Resize - Consider auto-resize for dynamic content
  6. Accessibility - Always associate with labels and provide context
  7. Performance - Debounce onChange handlers for expensive operations
  8. Mobile Optimization - Ensure proper mobile keyboard and sizing