Skip to content

Input

Class-based input component with label, help text, error state, and accessible markup.


Classes

ClassDescription
.inputBase input styling (border, font, transitions)
.input--smSmall size
.input--mdMedium size (default)
.input--lgLarge size
.input--errorError border color and focus ring
.input--disabledDisabled opacity and cursor
.input--readonlyReadonly background
.input-fieldWrapper for label + input + help/error
.input-field--blockFull-width wrapper
.input-labelLabel text
.input-label__requiredRequired asterisk
.input-helpHelp text below input
.input-errorError message text

Sizes

html
<input class="input input--sm" placeholder="Small" />
<input class="input input--md" placeholder="Medium" />
<input class="input input--lg" placeholder="Large" />

With Label & Help Text

Enter your full legal name

html
<div class="input-field">
  <label class="input-label" for="name">
    Full name <span class="input-label__required">*</span>
  </label>
  <input id="name" class="input input--md" type="text" placeholder="John Doe"
    required aria-required="true" />
  <p class="input-help">Enter your full legal name</p>
</div>

Error State

html
<div class="input-field">
  <label class="input-label" for="username">Username</label>
  <input id="username" class="input input--md input--error" type="text"
    aria-invalid="true" aria-describedby="username-error" />
  <p id="username-error" class="input-error" role="alert">
    Username is already taken
  </p>
</div>

Disabled & Readonly

html
<input class="input input--md" disabled value="Cannot edit" />
<input class="input input--md" readonly value="Read only" />

Accessibility

  • Associate <label> with input via for/id
  • Set aria-invalid="true" when in error state
  • Point aria-describedby to help or error text element
  • Use role="alert" on error text for screen reader announcement
  • Set aria-required="true" on required fields