This component documentation is currently being developed. Some features may be incomplete.
Textarea Input
View in Pattern LabHTML Markup
<textarea class="hoo-input-text" id="toggle-97" >
</textarea>
Textarea Input
A multi-line text input field for longer text entries.
Overview
The textarea input provides a resizable, multi-line field for users to enter larger amounts of text, such as comments, descriptions, or other content that wouldn’t fit in a standard text input.
Usage
Textarea inputs should be used when:
- The expected input is longer than a single line
- Users need to enter paragraphs or formatted text
- The content needs to be visible all at once (not truncated)
- The amount of text can vary significantly
Attributes
rows- Specifies the visible number of linescols- Specifies the visible widthmaxlength- Limits the maximum number of charactersplaceholder- Provides hint text when the field is emptyreadonly- Makes the textarea non-editable but still selectabledisabled- Makes the textarea completely non-interactive
States
- Default - Normal state
- Focus - When the textarea has keyboard focus
- Disabled - When the textarea cannot be interacted with
- Readonly - When the textarea is read-only
- Invalid - When the content doesn’t meet validation requirements
SCSS
Component Import
SCSS Partial Location
CSS Classes
.hoo-textarea- Base textarea class.hoo-textarea:disabled- Style applied to disabled textareas.hoo-textarea:invalid- Style applied when validation fails.hoo-textarea:focus- Style applied when the textarea has focus.hoo-textarea[readonly]- Style applied to readonly textareas
Accessibility
- Always associate with a
<label>element using matchingforandidattributes - Use
aria-describedbyto link the textarea to helper text or validation messages:<textarea id="comment" aria-describedby="comment-help"></textarea> <div id="comment-help">Maximum 500 characters</div> - Add
aria-required="true"for required textareas in addition to therequiredattribute - When disabled, include both the
disabledattribute andaria-disabled="true" - Use appropriate contrast for placeholder text (minimum 4.5:1 ratio)
- If implementing a character counter, associate it using
aria-describedby:<textarea id="description" aria-describedby="char-count"></textarea> <div id="char-count">0/200 characters</div> - For validation errors, use
aria-invalid="true"and link to error messages witharia-describedby - Consider setting an appropriate
aria-labelif the visual label is not sufficient
Customization
The textarea component can be customized in several ways:
Height - Use the
rowsattribute to control the initial heightWidth - Use the
colsattribute or CSS width property to control the widthResizing behavior - Control resizing with CSS:
Maximum length - Use the
maxlengthattribute to limit input lengthPlaceholder text - Use the
placeholderattribute for hint textSpellchecking - Control spell checking with the
spellcheckattribute:<textarea spellcheck="true" class="hoo-textarea"></textarea>
Example with Custom Attributes
<textarea
class="hoo-textarea"
id="custom-textarea"
rows="6"
maxlength="500"
placeholder="Enter your feedback (max 500 characters)"
spellcheck="true"
style="resize: vertical; min-height: 100px;">
</textarea>