The input
component represents an
<input>
element with an explicitly associated
<label>
element. The component also supports
additional information and/or error messages associated with the
input.
text
, tel
,
email
, password
, search
,
url
and other valid options.placeholder
attribute can be added to the
<input>
element but should never be used as a
replacement for the <label>
element.required
attribute
must also be applied to the <input>
element.input--invalid
attribute
should be injected into the parent container.input--disabled
attribute can be added to the
parent container if the form control needs to be disabled.<label>
must be prgrammatically
associated with the <input>
element.<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
attribute must
also be applied to the <input>
element.<input>
element should be definedUsed to display an <input>
form control and an
explicitly associated <label>
.
<div class="input">
<label class="input__label" for="example1">
<span class="input__content">Label for input</span>
<input class="input__control" type="text" name="example1" id="example1">
</label>
</div>
A help mesage can be placed directly after the
<label>
element using the message--help
class.
<div class="input">
<label class="input__label" for="example5">
<span class="input__content">Label for input</span>
<span class="message--help">Help message</span>
<input class="input__control" type="text" id="example5">
</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 <input>
.
<div class="input">
<label class="input__label" for="example6">
<span class="input__content">Label for input <span class="message--required">(Required)</span></span>
<input class="input__control" type="text" id="example6" required>
</label>
</div>
Used to display an <input>
form control and an
explicitly associated <label>
. The
<label>
is not displayed on-screen, but is still
available to assistive technologies.
<div class="input input--hidden">
<label class="input__label" for="example4">
<span class="input__content">Label for input</span>
<input class="input__control" type="text" id="example4">
</label>
</div>
Used to inform the user that the form control has not been filled-in correctly.
<div class="input input--invalid">
<label class="input__label" for="example7">
<span class="input__content">Label for input <span class="message--required">(Required)</span></span>
<input class="input__control" type="text" id="example7" required>
<!-- 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 <input>
element and
label. The disabled
boolean attribute must be added to
the <input>
.
<div class="input input--disabled">
<label class="input__label" for="example8">
<span class="input__content">Label for input</span>
<input class="input__control" type="text" id="example8" disabled>
</label>
</div>