Overview
HuxTextarea is a customizable multi-line text input component with consistent styling and extensive customization options. It provides a clean, modern textarea with support for labels, hints, validation, and character counting while automatically adapting to light and dark themes. Optimized for longer text input with proper height handling.Basic Usage
Simple Textarea
Textarea with Character Count
Textarea with Validation
Textarea with Error State
Properties
Core Properties
label- Optional field label text displayed above the textareahint- Placeholder text displayed inside the textarea when emptycontroller- TextEditingController for managing input stateonChanged- Callback triggered when the textarea value changesonSubmitted- Callback triggered when the user submits the textarea
Validation Properties
validator- Form validation function that returns error text or nullerrorText- Custom error message (overrides validator output)helperText- Helper text displayed below the textarea
Behavior Properties
enabled- Whether the textarea is interactive (default: true)minLines- Minimum number of text lines (default: 3)maxLines- Maximum number of text lines (default: 6)maxLength- Maximum character lengthshowCharacterCount- Whether to show character count when maxLength is set (default: false)keyboardType- Type of keyboard to displaytextInputAction- Action button for the keyboard
Layout Properties
width- Custom width (default: full width)
Styling & Dimensions
Dimensions
- Border Radius: 8px (rounded corners)
- Font Size: 14px with 1.4 line height
- Horizontal Padding: 12px (compact padding for better text density)
- Vertical Padding: 12px
Theme Support
- Automatically adapts to light and dark themes
- Uses HuxTokens for consistent theming
- Label uses FontWeight.w400 for lighter appearance
Character Count
WhenmaxLength is set and showCharacterCount is true, the textarea displays a character counter in the format “X / Y” at the bottom right. The counter updates dynamically as you type.
Examples
Basic Form with Textarea
Disabled Textarea
Best Practices
- Use
minLinesto set the initial visible height - Set
maxLinesto prevent the textarea from growing too large - Use
showCharacterCountwhen you have amaxLengthto help users stay within limits - Provide helpful
helperTextto guide users on what to enter - Use validation to ensure data quality