Text inputs are form inputs that gather plain text information from users. These classes are designed for <input type="text"> elements or <textarea> elements. An associated label is required. Optional placeholder and caption elements can also be added.
<input type="text" class="c-text-input" placeholder="Text input placeholder" />
<textarea name="" id="" class="c-textarea" placeholder="Textarea placeholder"></textarea>
In addition to the default state, both types of text inputs have hover, focus, change, blur and error states. The error state must be used with an input error component. Use c-text-input--error to apply the error state. An optional disabled state is also available. Use c-text-input--disabled to apply the disabled state.
<input type="text" class="c-text-input--disabled" placeholder="Text input placeholder" value="John Doe" disabled />
<textarea
name=""
id="text-area"
class="c-textarea c-textarea--disabled"
placeholder="The quick brown fox jumps over the lazy dog."
></textarea>
A text input or text area in the error state must be used with an input error component to guide the user in correcting the error.
<div>
<input
type="text"
class="c-text-input c-text-input--error"
placeholder="e.g. Homer J. Simpson"
id="text-input-1"
/>
<span class="c-inline-error">
<i class="icon icon--error c-inline-error__icon"></i>
<span class="c-inline-error__content">
Tell me something good.
</span>
</span>
</div>
A text input or text area in the error state must be used with an input error component to guide the user in correcting the error.
<div>
<textarea
name=""
id="text-area"
class="c-textarea c-textarea--error"
placeholder="The quick brown fox jumps over the lazy dog."
></textarea>
<span class="c-inline-error">
<i class="icon icon--error c-inline-error__icon"></i>
<span class="c-inline-error__content">
Tell me something good.
</span>
</span>
</div>
Use .l-margin-vertical--medium between the text input and any components above or below it. Text inputs will fill 100% width of the parent container when standing alone. When inline with another component, they will fill 50% width. Use .l-margin-horizontal--medium between the text input and any inline components.
Placeholders should give the user an example or show the required format of the input. Never use a placeholder instead of a label, as the user will lose the prompt once they begin typing. Use sentence case with no end punctuation, unless otherwise dictated by the input format.