Text areas are inputs that provide affordance to capture multiple lines of content from a user. There are two variations, one that relies on default markup and another that provides users with a counter when a maximum number of characters has been assigned.
Examples
Usage
Rules
- Include matching
for
andid
values unique to each label and input pair to associate the two - Use a text area when the length of the text input is expected to be larger than a few words
- The visible maximum characters pattern (x of x characters remaining) relies on
data
attributes for behavior
Constraints
- Use the
rows
andcolumns
attributes to physically limit the size of the<textarea>
- Use the
maxlength
attribute to limit the number of characters allowed - Only use a
fieldset
withlegend
to group associated inputs (e.g. multiple address inputs or credit card month/year inputs) or a set of radios or checkboxes. Some assistive tools will read the contents of the legend before each nested input to maintain context for a user.
Principles
- Text areas let a user know you‘re expecting more information from them than a one line response
Accessibility
- Always include
.label-help
text when an input requires explanation for expected formatting or error correction - When using
.label-help
you should usearia-describedby
on the element that the helper text applies to - The
textarea
withmaxlength
anddata
attributes that displays a character counter automatically creates a screen reader-only element to relay the character count to screen reader users after a longer pause when adding, removing or pasting content within the input - An invalid input should include the
aria-invalid="true"
attribute
Class Names
form-group Required |
Use on the parent |
form-control Required |
Apply to the |
form-group-spacer Modifier |
Use with |
has-warning Modifier |
Use with the |
has-danger Modifier |
Use on the |
- Last updated May 1, 2019
- Authorable - Yes
- Core - Text Areas