Skip to main content
The Textarea component provides a flexible multi-line text input field with support for labels, validation, auto-resize, and character counting.

Basic usage

<flx-textarea
  label="Description"
  placeholder="Enter a description..."
  [(ngModel)]="description">
</flx-textarea>

Properties

label
string
Label text displayed above the textarea
placeholder
string
Placeholder text shown when textarea is empty
value
string
The current value of the textarea
rows
number
default:"3"
Number of visible text lines
disabled
boolean
default:"false"
Disables the textarea
readonly
boolean
default:"false"
Makes the textarea read-only
required
boolean
default:"false"
Marks the field as required
error
boolean | string
default:"false"
Shows error state. Pass a string to display error message
helperText
string
Helper text displayed below the textarea
maxLength
number
Maximum number of characters allowed
showCharCount
boolean
default:"false"
Shows character count indicator
autoResize
boolean
default:"false"
Automatically adjusts height based on content
minHeight
string
Minimum height when autoResize is enabled (e.g., ‘100px’)
maxHeight
string
Maximum height when autoResize is enabled (e.g., ‘300px’)

Events

valueChange
EventEmitter<string>
Emitted when the textarea value changes
blur
EventEmitter<FocusEvent>
Emitted when the textarea loses focus
focus
EventEmitter<FocusEvent>
Emitted when the textarea receives focus

Examples

<flx-textarea
  label="Bio"
  placeholder="Tell us about yourself..."
  [maxLength]="500"
  [showCharCount]="true"
  [(ngModel)]="bio">
</flx-textarea>

Styling

Customize the Textarea component using CSS custom properties:
flx-textarea {
  --flx-textarea-min-height: 80px;
  --flx-textarea-padding: 8px 12px;
  --flx-textarea-border-radius: 4px;
  --flx-textarea-border-color: #d1d5db;
  --flx-textarea-focus-border-color: #3b82f6;
  --flx-textarea-error-border-color: #ef4444;
  --flx-textarea-background: #ffffff;
  --flx-textarea-text-color: #111827;
  --flx-textarea-placeholder-color: #9ca3af;
}

Accessibility

The Textarea component automatically handles:
  • Proper label association with for and id attributes
  • aria-required for required fields
  • aria-invalid for fields with errors
  • aria-describedby for helper text and error messages
  • Character count announcements for screen readers

Best practices

  • Use autoResize for better user experience with variable content lengths
  • Always set maxLength to prevent excessive input
  • Enable showCharCount when using maxLength to provide visual feedback
  • Provide clear helper text explaining the expected input format
  • Use appropriate rows value based on expected content length
  • Consider minHeight and maxHeight to prevent layout shifts
For long-form content entry, enable both autoResize and showCharCount to help users track their progress against any character limits.
  • Input - Single-line text input
  • Select - Dropdown selection

Build docs developers (and LLMs) love