Text Area
Text Area is a multi-line text input component for collecting longer text from users. Use it for forms, comments, descriptions, and any content requiring multiple lines of text input.View source →Text Area is a multi-line text input component for collecting longer text from users. Use it for forms, comments, messages, descriptions, and any content requiring multiple lines of text input. The component supports error validation, resizing options, and all the variant styles from the design system.
This is an enhanced version of the native HTML <textarea> element, styled to match the Kookie UI design system.
Playground
Installation
shellUsage
tsxProps
The TextArea component is the textarea element that accepts multi-line text input.
Variants
Use the variant prop to set textarea style.
Classic
Elevated style with subtle shadow for maximum visual prominence and important inputs.
tsxSurface
Standard surface style for form inputs and general text entry.
tsxSoft
Subtle background for secondary inputs and content-heavy interfaces.
tsxOutline
Bordered style for defined boundaries and structured forms.
tsxGhost
Minimal style for inline editing and seamless integration with text content.
tsxSizes
Set size for textarea density: 1 (80px min height), 2 (96px), 3 (120px). Use 3 for comfortable multi-line editing. Supports responsive objects like { initial: '1', sm: '2', md: '3' }.
Size 1
For compact interfaces and limited space.
tsxSize 2
For standard form contexts and general interfaces.
tsxSize 3
For comfortable editing and longer content.
tsxColors
Use the color prop with semantic colors to communicate textarea purpose or status. The color affects the focus state and can be used for visual categorization.
tsxMaterial
Use the material prop to set textarea appearance. Choose solid for opaque backgrounds, or translucent for depth and separation over images or dynamic backgrounds.
Theme
TextArea automatically inherits the theme's material setting.
tsxCustom
Override the theme's material for specific effects.
tsxResize
Control how users can resize the textarea with the resize prop.
None
Prevent resizing for fixed layouts.
tsxVertical
Allow vertical resizing only (most common for multi-line text).
tsxHorizontal
Allow horizontal resizing only.
tsxBoth
Allow resizing in both directions.
tsxStates
Error
Use error and errorMessage props to show validation errors. Error messages are automatically connected to the textarea via ARIA attributes.
tsxDisabled
Set disabled to prevent interaction when textarea is unavailable.
tsxRead Only
Use readOnly to make textarea non-editable while keeping it focusable and copyable.
tsxExamples
Comment Form
Collect user comments with appropriate sizing and validation.
tsxProduct Description
Use soft variant for content creation interfaces.
tsxFeedback Form
Structured form input with outline variant.
tsxCode Snippet Input
Fixed size textarea for code or formatted text.
tsxNote Taking
Expandable textarea for note-taking interfaces.
tsxCharacter Counter
Show remaining characters for limited text input.
tsxResponsive
Use responsive objects with the size prop to adapt textarea sizing across different breakpoints. The component uses a mobile-first approach.
tsxBreakpoints
Accessibility
TextArea provides comprehensive accessibility through ARIA attributes and semantic HTML.
Keyboard Navigation
- Tab - Move focus to/from textarea
- Enter - Insert new line
- Escape - Clear focus (browser default)
- Arrow Keys - Navigate cursor within text
- Shift + Arrow Keys - Select text
- Ctrl/Cmd + A - Select all text
ARIA Attributes
aria-invalid="true"- Automatically set when error or isInvalid is truearia-describedby- Links to error message for screen reader announcementsaria-labelledby- Links to external label elementrole="alert"- Error messages are announced immediatelyaria-live="polite"- Error message updates are announced
Screen Readers
- Error messages are automatically associated with the textarea
- Required fields can be marked with
requiredprop - Placeholder text provides hints without replacing labels
- Multi-line editing is properly announced
Best Practices
- Always provide a label (use
aria-labelledbyif label is external) - Use
errorMessageinstead of justerrorfor clear feedback - Provide placeholder as hints, not as replacement for labels
- Mark required fields with
requiredprop - Consider
maxLengthfor forms with character limits - Ensure sufficient color contrast for all states
- Use appropriate
rowsattribute for initial size
Enhancements
Kookie UI extends the native textarea with practical improvements:
Enhanced Error States
Rich error handling with error and errorMessage props. Error messages automatically associate with textarea via aria-describedby for screen reader accessibility. Visual error indicators appear in both light and dark themes.
Material System
Full integration with the material system for solid and translucent backgrounds. Automatic backdrop blur on translucent materials for depth and visual hierarchy.
Advanced Validation
Built-in support for required fields, min/max length validation, and character counting. Form integration with native HTML validation attributes and proper error messaging.
Responsive Sizing
Size prop supports responsive objects for adaptive sizing across breakpoints. Mobile-first approach ensures optimal experience on all devices.
Changelog
Added
- Error validation system with
error,errorMessage, andisInvalidprops - Automatic ARIA attributes for error messages and validation states
- Material prop for solid/translucent theme contexts
- Resize control with
resizeprop for user resizing behavior - Responsive size support with breakpoint objects
- Enhanced focus states with better contrast
- Character limit support with
maxLengthandminLengthprops
Changed
- Enhanced focus states with better contrast
- Improved error state styling with clearer visual feedback
- Better placeholder styling for all variants
Deprecated
panelBackgroundprop in favor ofmaterialprop
Fixed
- Error messages properly linked via ARIA for screen readers
- Focus management for all interactive states
- Scrollbar styling consistency across browsers
- Autofill color handling for password managers