Text input

Validation message here
Optional helper text goes here
Optional helper text here; if message is more than one line text should wrap (~100 character count maximum)
Optional helper text goes here
Vanilla JS
Code:
<!--
  Copyright IBM Corp. 2016, 2018

  This source code is licensed under the Apache-2.0 license found in the
  LICENSE file in the root directory of this source tree.
-->

<div 
  class="bx--form-item bx--text-input-wrapper">
  <label for="text-input-3" class="bx--label">Text Input label</label>
  <div class="bx--text-input__field-wrapper">
    <input id="text-input-3" type="text"
      class="bx--text-input" placeholder="Placeholder text">
  </div>
</div>

<div 
  class="bx--form-item bx--text-input-wrapper">
  <label for="text-input-4" class="bx--label">Text Input label</label>
  <div class="bx--text-input__field-wrapper" data-invalid>
    <svg focusable="false" preserveAspectRatio="xMidYMid meet" style="will-change: transform;" xmlns="http://www.w3.org/2000/svg" class="bx--text-input__invalid-icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 1C4.2 1 1 4.2 1 8s3.2 7 7 7 7-3.1 7-7-3.1-7-7-7zm-.5 3h1v5h-1V4zm.5 8.2c-.4 0-.8-.4-.8-.8s.3-.8.8-.8c.4 0 .8.4.8.8s-.4.8-.8.8z"></path><path d="M7.5 4h1v5h-1V4zm.5 8.2c-.4 0-.8-.4-.8-.8s.3-.8.8-.8c.4 0 .8.4.8.8s-.4.8-.8.8z" data-icon-path="inner-path" opacity="0"></path></svg>
    <input id="text-input-4" type="text"
      class="bx--text-input bx--text-input--invalid "
      placeholder="Placeholder text">
  </div>
  <div class="bx--form-requirement">
    Validation message here
  </div>
</div>

<div 
  class="bx--form-item bx--text-input-wrapper">
  <label for="text-input-5" class="bx--label">Text Input label</label>
  <div class="bx--form__helper-text">
    Optional helper text goes here
  </div>
  <div class="bx--text-input__field-wrapper">
    <input id="text-input-5" type="text"
      class="bx--text-input" placeholder="Placeholder text">
  </div>
</div>

<div 
  class="bx--form-item bx--text-input-wrapper"
  style="width: 320px">
  <label for="text-input-6" class="bx--label">Text Input label</label>
  <div class="bx--form__helper-text">
    Optional helper text here; if message is more than one line text should wrap (~100 character count maximum)
  </div>
  <div class="bx--text-input__field-wrapper">
    <input id="text-input-6" type="text"
      class="bx--text-input" placeholder="Placeholder text">
  </div>
</div>

<div 
  class="bx--form-item bx--text-input-wrapper">
  <label for="text-input-7" class="bx--label bx--label--disabled">Text Input label</label>
  <div class="bx--form__helper-text bx--form__helper-text--disabled">
    Optional helper text goes here
  </div>
  <div class="bx--text-input__field-wrapper">
    <input id="text-input-7" type="text"
      class="bx--text-input" placeholder="Placeholder text"
      disabled>
  </div>
</div>
Validation message here
Optional helper text goes here
Optional helper text goes here
Vanilla JS
Code:
<!--
  Copyright IBM Corp. 2016, 2018

  This source code is licensed under the Apache-2.0 license found in the
  LICENSE file in the root directory of this source tree.
-->

<div class="bx--form-item">
  <label for="text-area-2" class="bx--label">Text Area label</label>
  <div class="bx--text-area__wrapper">
    <textarea id="text-area-2"
      class="bx--text-area bx--text-area--v2"
      rows="4" cols="50" placeholder="Placeholder text."></textarea>
  </div>
</div>

<div class="bx--form-item">
  <label for="text-area-3" class="bx--label">Text Area label</label>
  <div class="bx--text-area__wrapper" data-invalid>
    <svg focusable="false" preserveAspectRatio="xMidYMid meet" style="will-change: transform;" xmlns="http://www.w3.org/2000/svg" class="bx--text-area__invalid-icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 1C4.2 1 1 4.2 1 8s3.2 7 7 7 7-3.1 7-7-3.1-7-7-7zm-.5 3h1v5h-1V4zm.5 8.2c-.4 0-.8-.4-.8-.8s.3-.8.8-.8c.4 0 .8.4.8.8s-.4.8-.8.8z"></path><path d="M7.5 4h1v5h-1V4zm.5 8.2c-.4 0-.8-.4-.8-.8s.3-.8.8-.8c.4 0 .8.4.8.8s-.4.8-.8.8z" data-icon-path="inner-path" opacity="0"></path></svg>
    <textarea id="text-area-3"
      class="bx--text-area bx--text-area--invalid bx--text-area--v2"
      rows="4" cols="50" placeholder="Placeholder text."></textarea>
  </div>
  <div class="bx--form-requirement">
    Validation message here
  </div>
</div>

<div class="bx--form-item">
  <label for="text-area-4" class="bx--label">Text Area label</label>
  <div class="bx--form__helper-text">
    Optional helper text goes here
  </div>
  <div class="bx--text-area__wrapper">
    <textarea id="text-area-4"
      class="bx--text-area bx--text-area--v2"
      rows="4" cols="50" placeholder="Placeholder text."></textarea>
  </div>
</div>

<div class="bx--form-item">
  <label for="text-area-5" class="bx--label bx--label--disabled">Text Area label</label>
  <div class="bx--form__helper-text bx--form__helper-text--disabled">
    Optional helper text goes here
  </div>
  <div class="bx--text-area__wrapper">
    <textarea id="text-area-5" class="bx--text-area bx--text-area--v2" rows="4"
      cols="50" placeholder="Placeholder text." disabled></textarea>
  </div>
</div>

Documentation

SCSS

Modifiers

Use these modifiers with .bx--form-item[data-text-input] class.

Default Selector Description
.bx--text-input-password-visible The className for a password field that is revealing text

JavaScript

Public Methods

Name Params Description
release Deletes the instance

Options

Option Default Selector Description
selectorInit [data-text-input] The selector to find the text input form groups
selectorPasswordField .bx--text-input[data-toggle-password-visibility] The selector to find the input field
selectorPasswordVisibilityButton .bx--text-input--password__visibility__toggle The selector to find the password visibility toggle
selectorPasswordVisibilityTooltip .bx--text-input--password__visibility__toggle > .bx--assistive-text The selector to find the password visibility toggle tooltip
passwordIsVisible .bx--text-input--password-visible The className for a field with visible passwords

Classes

Default Selector Description
.bx--text-input-password-visible The className for a password field that is revealing text