Input
Text-like inputs: text, email, password, search, tel, url, number, and the date and time family, which get an icon on the trailing edge.
| Class | Does what |
|---|---|
input | Full-width field with the shared control surface |
input-error | Error color, for when aria-invalid is not available |
Basic
<input type="text" class="input" placeholder="Text" />
<input type="email" class="input" placeholder="you@example.com" />
<input type="password" class="input" value="hunter2" />
<input type="text" placeholder="Text" />
<input type="email" placeholder="you@example.com" />
<input type="password" value="hunter2" />
Date and time
<input type="date" class="input" />
<input type="time" class="input" />
<input type="month" class="input" />
<input type="date" />
<input type="time" />
<input type="month" />
Invalid and disabled
<input type="text" class="input" aria-invalid="true" value="Invalid" />
<input type="text" class="input" value="Disabled" disabled />
<input type="text" aria-invalid="true" value="Invalid" />
<input type="text" value="Disabled" disabled />
Classless: every <code>input</code> gets this styling except checkbox, radio, range, file, color, and the button types, which are styled as buttons.
Composition
Common ways to put this together with other components. The general rules are on Composition.
Inline sign-up
A heading, a sentence, one field and a button.
<form class="prose">
<h2>Newsletter</h2>
<p>A short note when there is something new.</p>
<div class="field-row">
<label class="label" style="flex: 1">
<p>Email</p>
<input class="input" type="email" placeholder="you@example.com" autocomplete="email" />
</label>
<button class="btn btn-secondary">Subscribe</button>
</div>
</form>
- Spacing: in the row, the field keeps its
1rembottom margin and the label adds0.375remof its own. The button takes both,calc(1rem * 1.375), to line its bottom edge up with the field's. - Layout:
.flipstacks them on a phone, androw-gap: 0stops the row's gap adding to the margins once stacked.
Search above results
A search field and a count, then the results.
<label class="label">
<p>Search</p>
<input class="input" type="search" placeholder="Title or topic" />
</label>
<p class="text-secondary"><small>12 results</small></p>
- Text: the count is
.text-secondaryand sits between the field and the results, belonging to neither.