Text Area
Text areas allow for the collection of input longer than a single line.
Example
Default text area
row
classHover
Disabled
disabled
class if you want to disable the text areaAnatomy
- Label: Inform users of what data should be put into the field, labels must always be outside of the text field.
- Word count (situational): Serves to let users know the max number of characters is allowed and when they have gone over.
Spacing
Within the text area
Ensure that there is a min of 16px horizontal spacing and 8px vertical spacing within the text area.
Usage guidelines
Best practices:
- Provide additional instructions or hint text to guide users on what to enter.
- If the hint text is insufficient to guide users, you can use placeholder text to provide examples of the expected input. However, placeholders should not replace labels.
- Ensure the placeholder text has sufficient colour contrast to be readable.
- If there is a character limit, do inform users about it.
- Use a readable font size and line height to enhance legibility.
Text area should be used when:
- Users are required to enter more than a line of text.
Text area should not be used when:
- Questions are too complex. We recommend that you break your questions up into a series of simpler questions instead. For example, consider using the checkbox component if you want users to give multiple answers from a predetermined set of options.
Usability guidelines
Use character count
If there is a character limit, inform users about it.
Labels should be placed outside of the text field
Labels should be above or next to the text field. This ensures a clear association between the label and the input field, and is also crucial for screen readers and other assistive technologies.
Do not rely solely on placeholder text to convey critical information
Placeholder text disappears when a text input is filled in, which can make it easy for users to forget the guidance or format instructions, leading to errors or confusion.
Behaviour
Users should be able to click anywhere within the text area to focus. On focus, users can type directly into the text area. Any placeholder text in the field will be replaced when the user begins typing.
Accessibility guidelines
Aria attributes
-
Use the
label
element to associate text with form elements explicitly. -
The
for
attribute of the label must exactly match theid
of the form control.
Keyboard accessibility
- Tab to bring focus to the text area.
Focus indicator
- Ensure the focus indicator is highly visible. Use a distinct colour that contrasts well with the surrounding elements. Avoid relying on colour alone; consider adding a border or shadow to enhance visibility so that it is accessible to all users, including those with visual impairments.
- The focus indicator should encompass the entire text area without altering its size or shape. It should be clear that the focus is on the text area, not another part of the UI.
Last updated 02 October 2024