Input

Use input to allow users to enter a single line of text. The text can be letters, numbers or punctuation.

Default

.e-input

<div class="e-field">
  <label class="e-field__label" for="input1">
    Form input label
  </label>
  <input class="e-input" id="input1" type="text" placeholder="Placeholder">
</div>
<div class="e-field">
  <label class="e-field__label" for="input1">
    Form input label
  </label>
  <input class="e-input" id="input1" type="text" placeholder="Placeholder">
</div>
JavaScript

Sizes

Small.e-input-small

<div class="doc-field">
  <label class="e-field__label" for="textarea2">
    Form input label
  </label>
  <input class="e-input e-input-small" id="textarea2" type="text" placeholder="Placeholder">
</div>
<div class="doc-field">
  <label class="e-field__label" for="textarea2">
    Form input label
  </label>
  <input class="e-input e-input-small" id="textarea2" type="text" placeholder="Placeholder">
</div>
JavaScript

Medium.e-input-medium

<div class="doc-field">
  <label class="e-field__label" for="textarea2">
    Form input label
  </label>
  <input class="e-input e-input-medium" id="textarea2" type="text" placeholder="Placeholder">
</div>
<div class="doc-field">
  <label class="e-field__label" for="textarea2">
    Form input label
  </label>
  <input class="e-input e-input-medium" id="textarea2" type="text" placeholder="Placeholder">
</div>
JavaScript

Large.e-input-large

<div class="doc-field">
  <label class="e-field__label" for="textarea2">
    Form input label
  </label>
  <input class="e-input e-input-large" id="textarea2" type="text" placeholder="Placeholder">
</div>
<div class="doc-field">
  <label class="e-field__label" for="textarea2">
    Form input label
  </label>
  <input class="e-input e-input-large" id="textarea2" type="text" placeholder="Placeholder">
</div>
JavaScript

Variations

Error.e-input-error

<div class="e-field">
  <label class="e-field__label" for="input3">
    Form input label
  </label>
  <input class="e-input e-input-error" id="input3" placeholder="Placeholder">
</div>
<div class="e-field">
  <label class="e-field__label" for="input3">
    Form input label
  </label>
  <input class="e-input e-input-error" id="input3" placeholder="Placeholder">
</div>
JavaScript

Error with message.e-input-error

<div class="e-field">
  <label class="e-field__label" for="input10">
    Form input label
  </label>
  <input class="e-input e-input-error" id="input10" placeholder="Placeholder">
  <span class="e-field__message e-field__message-error">
    An error occured
  </span>
</div>
<div class="e-field">
  <label class="e-field__label" for="input10">
    Form input label
  </label>
  <input class="e-input e-input-error" id="input10" placeholder="Placeholder">
  <span class="e-field__message e-field__message-error">
    An error occured
  </span>
</div>
JavaScript
An error occured

Disabled:disabled, .e-input-disabled

<div class="e-field">
  <label class="e-field__label" for="input2">
    Form input label
  </label>
  <input class="e-input" id="input2" disabled placeholder="Placeholder">
</div>
<div class="e-field">
  <label class="e-field__label" for="input2">
    Form input label
  </label>
  <input class="e-input" id="input2" disabled placeholder="Placeholder">
</div>
JavaScript

Code.e-input-code

<div class="e-field">
  <label class="e-field__label" for="input4">
    Form input label
  </label>
  <input class="e-input e-input-code" id="input4" placeholder="Placeholder">
</div>
<div class="e-field">
  <label class="e-field__label" for="input4">
    Form input label
  </label>
  <input class="e-input e-input-code" id="input4" placeholder="Placeholder">
</div>
JavaScript

Emoji pickere-emojipicker

<div class="e-field">
  <label class="e-field__label" for="input6">
    Emoji input
  </label>
  <e-emojipicker class="e-emojipicker">
    <e-emoji>
      <input class="e-input" id="input6" is="e-emoji" placeholder="Placeholder">
    </e-emoji>
  </e-emojipicker>
</div>
<div class="e-field">
  <label class="e-field__label" for="input6">
    Emoji input
  </label>
  <e-emojipicker class="e-emojipicker">
    <e-emoji>
      <input class="e-input" id="input6" is="e-emoji" placeholder="Placeholder">
    </e-emoji>
  </e-emojipicker>
</div>
JavaScript

Input

Use input to allow users to enter a single line of text. The text can be letters, numbers or punctuation.

Best practices

Inputs should:

  • Be clearly labeled to define what information a user can enter. Use only a few words.
    • The label should be aligned to the left or above the input box, in harmony with the surrounding layout.
  • Have a placeholder text - when not edited - to provide a hint or example about what should be entered.
    • The placeholder text should be set in lighter color and with cursive to be visually distinguishable from the content typed in the input.
  • Have a helper message under the input box if the placeholder text is insufficient for further instructions.
  • Show the cursor when clicking into it.
  • Allow the user to write, edit, copy, paste or select text in it.
  • Have a red asterisk after its label if it is a mandatory field.
  • Support the format of the required data.
    • E.g. Auto fill hyphens and spaces when entering a credit card number.
  • Be in an environment which makes it clear when the data is submitted.

Try to avoid:

  • Using it for large amount of text that would only fit into multiple lines. Use the Textarea instead.
  • Using it for date input. Use the Datepicker instead.
  • Asking for a limited, predefined set options. If you know all the possible options, use Select instead. It is faster to use and more accurate.
  • Forcing the users to enter data twice.