Text area
Allows users to enter multiple lines of text.
Examples
Usage
Use a text area when the user needs to enter more than a single line of text, such as:
- answering an open-ended question
- writing comments or descriptions in a form
Do:
- use a text area for multi-line input
- include a clear, visible label describing what the user should enter
- show the character limit if there is one
- let users know how many characters they have left (if this is relevant and possible)
Avoid:
- using a text area for short, single-line input – instead use a text box
- using placeholder text because it may not work with assistive technologies, can fail colour contrast checks, and might be mistaken for pre-filled content
References
Parameters for turas-text-area
- asp-for - binds the text area to a model property
- guidance-text - provides additional guidance for the user
- field-column-widths - sets the column width for the text area
- additional-classes - allows for custom CSS classes to be added
- hide-validation-message - hides validation messages for the text area
- readonly - makes the text area read-only
- asp-is-disabled - disables the text area
- hide-label - hides the label for the text area
Close without saving
Are you sure you want to close without saving?
Any information you have entered will be lost!
Testing
Check that the textarea:
- can be used with a keyboard only, with no keyboard traps
- allows users to type, edit and delete text using only the keyboard
- shows a visible focus state when the textarea receives focus
- is announced correctly by screen readers, including its label, role and current value
- hint text or instructions are read out (for example, character limits or formatting guidance) by screen readers
- error messages are announced by screen readers and associated with the textarea
- input does not trigger unexpected changes while typing
- required fields are clearly communicated
- character limits (if present) are communicated clearly and updated as users type
- remains usable at 400% zoom and supports reflow without horizontal scrolling
Developer considerations
When using the textarea component in your form:
- provide a visible label using <label for=""> and an ID
- make sure the textarea has a programmatic name (via label or aria-labelledby)
- use aria-describedby to associate hint text and error messages with the textarea
- write error messages that explain what went wrong and how to fix it
- do not rely on placeholder text as a label
- make sure a visible focus state that meets contrast requirements
- make sure the textarea remains usable when text is resized and content reflows
- avoid auto-submitting or triggering unexpected changes while typing
- make sure sufficient touch target size and spacing, with a target size of at least 24 × 24 CSS pixels
- if a character limit is used, communicate it clearly
- update the character count correctly as users type
- provide feedback when users approach or exceed the limit
- make sure error states are clearly visible and are programmatically associated with the textarea
Required fields
If your form contains fields that users must complete:
- clearly indicate when the textarea is required by using a visual indicator such as an asterisk
- do not rely on the visual indicator alone (for example, an asterisk) to communicate that a field is required, include the help text “Required fields are marked with an asterisk *” at the top of every page of the form
- make sure the required state of the textarea is programmatically available to assistive technologies using aria-required="true"