The textarea
component represents an
<textarea>
element with an explicitly associated
<label>
element. The component also supports
additional information and/or error messages associated with the form
control.
hidden
attribute can be applied to the
<label>
element but only in specific circumstances.textarea--required
attribute should be added to
the parent container for all instances were the form control is
required. In these instances, the required
and
textarea--invalid
attribute
should be injected into the parent container.textarea--disabled
attribute can be added to the
parent container if the form control needs to be disabled.<label>
element should only be hidden in
cases where there is no other choices available, and only when the
form is extremely simple and its purpose is clear to sighted users.required
attributes must
be applied to <textarea>
element to inform
Assistive Technologies.<textarea>
element should be definedUsed to display a <textarea>
form control and an
explicitly associated <label>
.
<div class="textarea">
<label class="textarea__label" for="example">
<span class="textarea__content">Label for textarea</span>
<textarea class="textarea__control" id="example" rows="5"></textarea>
</label>
</div>
A help mesage can be placed directly after the
<label>
element using the message--help
class.
<div class="textarea">
<label class="textarea__label" for="example">
<span class="textarea__content">Label for textarea</span>
<span class="message--help">Help Message</span>
<textarea class="textarea__control" id="example" rows="5"></textarea>
</label>
</div>
A required flag can be placed inside the
<label>
element using the message--required
class. The required
boolean attribute must be added to
the <textarea>
.
<div class="textarea">
<label class="textarea__label" for="example">
<span class="textarea__content">Label for textarea <span class="message--required">(Required)</span></span>
<textarea class="textarea__control" id="example" rows="5" required></textarea>
</label>
</div>
Used to display a <textarea>
form control and an
explicitly associated <label>
. The
<label>
is not displayed on-screen, but is still
available to assistive technologies.
<div class="textarea textarea--hidden">
<label class="textarea__label" for="example">
<span class="textarea__content">Label for textarea</span>
<textarea class="textarea__control" id="example" rows="5"></textarea>
</label>
</div>
Used to inform the user that the form control has not been filled-in correctly.
<div class="textarea textarea--invalid">
<label class="textarea__label" for="example">
<span class="textarea__content">Label for textarea <span class="message--required">(Required)</span></span>
<textarea class="textarea__control" id="example" rows="5"></textarea>
<!-- Error message -->
<span class="message--error">
<span class="fas fa-times">
<span class="u-hidden">Error</span>
</span>
Error message
</span>
</label>
</div>
Used to present a disabled <textarea>
element and
label. The disabled
boolean attribute must be added to
the <textarea>
.
<div class="textarea textarea--disabled">
<label class="textarea__label" for="example">
<span class="textarea__content">Disabled textarea</span>
<textarea class="textarea__control" id="example" rows="5" disabled></textarea>
</label>
</div>