Form controls

TextArea
v1.1.2
Documentation Under Review

A multi-line text input component for capturing user feedback, comments, and longer text entries in product interfaces.

Overview

The Product TextArea component provides a flexible, multi-line text input optimized for product interfaces. It includes built-in support for character limits, validation states, and three size variants with product-specific typography.

Installation

npm install @pmi/catalyst-text-area

Usage

Basic TextArea

Preview

Variants

Sizes

The Product TextArea supports three size variants with product-optimized typography: sm, md (default), and lg.

Preview

States

Danger State

Use the danger prop to indicate validation errors or warning states.

Preview

Disabled State

The disabled state prevents user interaction and reduces opacity.

Preview

All States

Preview

Advanced Examples

Character Counter with Validation

Real-time character counting with validation feedback for user-generated content.

Preview

Form Field with Helper Text

Complete form field pattern with label, input, and contextual helper text.

Preview
Include steps to reproduce, expected behavior, and actual behavior

Tag Input Pattern

Use the asChild prop to create complex input patterns like tag chips with textarea.

Preview
React
TypeScript
Tailwind

Real-World Examples

Custom Styling

Infinity Theme Example

Custom styling for the Infinity product theme with aqua accent colors.

Preview

Accessibility

The Product TextArea component follows WCAG 2.1 AA guidelines:

  • Semantic HTML: Uses native <textarea> element for proper form integration
  • ARIA Labels: Associate with <Label> component using htmlFor and id attributes
  • ARIA Descriptions: Use aria-describedby to connect with helper text or error messages
  • ARIA Live Regions: Use aria-live="polite" for dynamic character count updates
  • ARIA Invalid: Set aria-invalid="true" when in danger/error state
  • Role Alert: Use role="alert" on error messages for immediate screen reader announcement
  • Focus Management: Clear focus indicators with 1px inset ring meeting contrast requirements
  • Keyboard Navigation: Full keyboard support with standard textarea interactions
  • Screen Reader Labels: Use .sr-only for icon-only content (e.g., "Error:")

API Reference

TextArea Props

PropTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Controls padding and text size (sm=text-sm, md=text-base, lg=text-lg)
dangerbooleanfalseApplies error/warning styling with red color scheme
disabledbooleanfalseDisables the textarea and reduces opacity to 40%
asChildbooleanfalseEnables composition by merging props onto child element
classNamestring-Additional CSS classes for custom styling
placeholderstring-Placeholder text when textarea is empty
defaultValuestring-Initial uncontrolled value
valuestring-Controlled value for state management
onChange(e: ChangeEvent<HTMLTextAreaElement>) => void-Change event handler
maxLengthnumber-Maximum character limit (enforced by browser)
rowsnumber-Number of visible text rows
colsnumber-Number of visible text columns
aria-labelstring-Accessible label for screen readers
aria-describedbystring-ID of element describing the textarea
aria-invalidboolean | 'true' | 'false'-Indicates validation state
aria-requiredboolean | 'true' | 'false'-Indicates if field is required
aria-live'polite' | 'assertive' | 'off'-Screen reader announcement behavior
unstyledbooleanfalseDisables all default CVA/Tailwind styling, only applies className.
  • Label - For labeling form fields (shared component)
  • SubText - For helper text and validation messages (shared component)
  • TextField - For single-line text input
  • Tag - For tag chip patterns with textarea

Best Practices

  1. Character Limits: Always show character counters when enforcing maxLength
  2. Validation Feedback: Provide clear, immediate feedback for validation errors
  3. Helper Text: Use SubText to guide users on expected input format
  4. Label Association: Always associate textarea with a Label using htmlFor/id
  5. Appropriate Sizing: Use sm for compact layouts, md for standard forms, lg for emphasized inputs
  6. Placeholder Text: Keep placeholder text concise and action-oriented
  7. Minimum Height: Default min-h-28 (7rem/112px) provides comfortable multi-line editing
  8. Resize Behavior: Allow default browser resize for user preference unless specifically constrained
  9. Monospace Font: Use font-mono for code or configuration inputs
  10. Accessibility: Always provide labels, descriptions, and appropriate ARIA attributes

On this page