Skip to main content
Text inputs enable the user to interact with and input data. Use when the application requires long-form content from the user.

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)

Vanilla JS

<!-- 
  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>
  <input id="text-input-3" type="text" class="bx--text-input" placeholder="Placeholder text">
</div>

<div  class="bx--form-item bx--text-input-wrapper">
  <label for="text-input-4" class="bx--label">Text Input label</label>
  <input data-invalid id="text-input-4" type="text" class="bx--text-input"
    placeholder="Placeholder text">
  <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>
  <input id="text-input-5" type="text" class="bx--text-input" placeholder="Placeholder text">
</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>
  <input id="text-input-6" type="text" class="bx--text-input" placeholder="Placeholder text">
</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>
  <input id="text-input-7" type="text" class="bx--text-input" placeholder="Placeholder text"
    disabled>
</div>

Password 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)

Vanilla JS

<!-- 
  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  data-text-input  class="bx--form-item bx--text-input-wrapper">
  <label for="text-input-3" class="bx--label">Text Input label</label>
  <input id="text-input-3" type="password" class="bx--text-input "
    placeholder="Placeholder text" data-toggle-password-visibility>
  <button class="bx--text-input--password__visibility bx--tooltip__trigger bx--tooltip--icon__bottom" aria-label="Show password">
      <svg class="bx--icon--visibility-off" hidden="true" width="16" height="16" viewBox="0 0 16 16">
        <path d="M11.846 3.45L15.293.007 16 .714l-3.284 3.281c1.261.902 2.377 2.212 3.347 3.93C14.02 11.642 11.333 13.5 8 13.5c-1.392 0-2.667-.324-3.822-.973L.703 16l-.706-.708 3.323-3.32C2.071 11.042.976 9.694.035 7.924 2.012 4.308 4.667 2.5 8 2.5c1.395 0 2.677.317 3.846.95zm-6.928 8.338c.944.477 1.97.712 3.082.712 2.795 0 5.076-1.483 6.907-4.568-.866-1.417-1.833-2.486-2.91-3.219l-1.55 1.55a3 3 0 0 1-4.185 4.182l-1.344 1.343zm-.882-.533l1.518-1.517A3 3 0 0 1 9.74 5.556l1.364-1.363A7.02 7.02 0 0 0 8 3.5c-2.798 0-5.047 1.439-6.819 4.432.842 1.465 1.792 2.568 2.855 3.323zm2.948-1.532a2 2 0 0 0 2.74-2.738l-2.74 2.738zm-.707-.707l2.74-2.738a2 2 0 0 0-2.74 2.738z"></path>
      </svg>
      <svg class="bx--icon--visibility-on" width="16" height="16" viewBox="0 0 16 11">
        <path d="M8 7.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 1c-1.7 0-3-1.3-3-3s1.3-3 3-3 3 1.3 3 3-1.3 3-3 3z"></path>
        <path d="M8 10c2.8 0 5.1-1.5 6.9-4.6C13.1 2.5 10.8 1 8 1 5.2 1 3 2.4 1.2 5.4 2.9 8.6 5.2 10 8 10zM8 0c3.3 0 6 1.8 8.1 5.4C14 9.2 11.3 11 8 11S2 9.2 0 5.5C2 1.9 4.6 0 8 0z"></path>
      </svg>
  </button>
</div>

<div  data-text-input  class="bx--form-item bx--text-input-wrapper">
  <label for="text-input-4" class="bx--label">Text Input label</label>
  <input data-invalid id="text-input-4" type="password" class="bx--text-input "
    placeholder="Placeholder text" data-toggle-password-visibility>
  <button class="bx--text-input--password__visibility bx--tooltip__trigger bx--tooltip--icon__bottom" aria-label="Show password">
      <svg class="icon--visibility-off" hidden="true" width="16" height="16" viewBox="0 0 16 16">
        <path d="M11.846 3.45L15.293.007 16 .714l-3.284 3.281c1.261.902 2.377 2.212 3.347 3.93C14.02 11.642 11.333 13.5 8 13.5c-1.392 0-2.667-.324-3.822-.973L.703 16l-.706-.708 3.323-3.32C2.071 11.042.976 9.694.035 7.924 2.012 4.308 4.667 2.5 8 2.5c1.395 0 2.677.317 3.846.95zm-6.928 8.338c.944.477 1.97.712 3.082.712 2.795 0 5.076-1.483 6.907-4.568-.866-1.417-1.833-2.486-2.91-3.219l-1.55 1.55a3 3 0 0 1-4.185 4.182l-1.344 1.343zm-.882-.533l1.518-1.517A3 3 0 0 1 9.74 5.556l1.364-1.363A7.02 7.02 0 0 0 8 3.5c-2.798 0-5.047 1.439-6.819 4.432.842 1.465 1.792 2.568 2.855 3.323zm2.948-1.532a2 2 0 0 0 2.74-2.738l-2.74 2.738zm-.707-.707l2.74-2.738a2 2 0 0 0-2.74 2.738z"></path>
      </svg>
      <svg class="icon--visibility-on" width="16" height="16" viewBox="0 0 16 11">
        <path d="M8 7.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 1c-1.7 0-3-1.3-3-3s1.3-3 3-3 3 1.3 3 3-1.3 3-3 3z"></path>
        <path d="M8 10c2.8 0 5.1-1.5 6.9-4.6C13.1 2.5 10.8 1 8 1 5.2 1 3 2.4 1.2 5.4 2.9 8.6 5.2 10 8 10zM8 0c3.3 0 6 1.8 8.1 5.4C14 9.2 11.3 11 8 11S2 9.2 0 5.5C2 1.9 4.6 0 8 0z"></path>
      </svg>
  </button>
  <div class="bx--form-requirement">
    Validation message here
  </div>
</div>

<div  data-text-input  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>
  <input id="text-input-5" type="password" class="bx--text-input "
    placeholder="Placeholder text" data-toggle-password-visibility>
  <button class="bx--text-input--password__visibility bx--tooltip__trigger bx--tooltip--icon__bottom" aria-label="Show password">
      <svg class="icon--visibility-off" hidden="true" width="16" height="16" viewBox="0 0 16 16">
        <path d="M11.846 3.45L15.293.007 16 .714l-3.284 3.281c1.261.902 2.377 2.212 3.347 3.93C14.02 11.642 11.333 13.5 8 13.5c-1.392 0-2.667-.324-3.822-.973L.703 16l-.706-.708 3.323-3.32C2.071 11.042.976 9.694.035 7.924 2.012 4.308 4.667 2.5 8 2.5c1.395 0 2.677.317 3.846.95zm-6.928 8.338c.944.477 1.97.712 3.082.712 2.795 0 5.076-1.483 6.907-4.568-.866-1.417-1.833-2.486-2.91-3.219l-1.55 1.55a3 3 0 0 1-4.185 4.182l-1.344 1.343zm-.882-.533l1.518-1.517A3 3 0 0 1 9.74 5.556l1.364-1.363A7.02 7.02 0 0 0 8 3.5c-2.798 0-5.047 1.439-6.819 4.432.842 1.465 1.792 2.568 2.855 3.323zm2.948-1.532a2 2 0 0 0 2.74-2.738l-2.74 2.738zm-.707-.707l2.74-2.738a2 2 0 0 0-2.74 2.738z"></path>
      </svg>
      <svg class="icon--visibility-on" width="16" height="16" viewBox="0 0 16 11">
        <path d="M8 7.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 1c-1.7 0-3-1.3-3-3s1.3-3 3-3 3 1.3 3 3-1.3 3-3 3z"></path>
        <path d="M8 10c2.8 0 5.1-1.5 6.9-4.6C13.1 2.5 10.8 1 8 1 5.2 1 3 2.4 1.2 5.4 2.9 8.6 5.2 10 8 10zM8 0c3.3 0 6 1.8 8.1 5.4C14 9.2 11.3 11 8 11S2 9.2 0 5.5C2 1.9 4.6 0 8 0z"></path>
      </svg>
  </button>
</div>

<div  data-text-input  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>
  <input id="text-input-6" type="password" class="bx--text-input "
    placeholder="Placeholder text" data-toggle-password-visibility>
  <button class="bx--text-input--password__visibility bx--tooltip__trigger bx--tooltip--icon__bottom" aria-label="Show password">
      <svg class="icon--visibility-off" hidden="true" width="16" height="16" viewBox="0 0 16 16">
        <path d="M11.846 3.45L15.293.007 16 .714l-3.284 3.281c1.261.902 2.377 2.212 3.347 3.93C14.02 11.642 11.333 13.5 8 13.5c-1.392 0-2.667-.324-3.822-.973L.703 16l-.706-.708 3.323-3.32C2.071 11.042.976 9.694.035 7.924 2.012 4.308 4.667 2.5 8 2.5c1.395 0 2.677.317 3.846.95zm-6.928 8.338c.944.477 1.97.712 3.082.712 2.795 0 5.076-1.483 6.907-4.568-.866-1.417-1.833-2.486-2.91-3.219l-1.55 1.55a3 3 0 0 1-4.185 4.182l-1.344 1.343zm-.882-.533l1.518-1.517A3 3 0 0 1 9.74 5.556l1.364-1.363A7.02 7.02 0 0 0 8 3.5c-2.798 0-5.047 1.439-6.819 4.432.842 1.465 1.792 2.568 2.855 3.323zm2.948-1.532a2 2 0 0 0 2.74-2.738l-2.74 2.738zm-.707-.707l2.74-2.738a2 2 0 0 0-2.74 2.738z"></path>
      </svg>
      <svg class="icon--visibility-on" width="16" height="16" viewBox="0 0 16 11">
        <path d="M8 7.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 1c-1.7 0-3-1.3-3-3s1.3-3 3-3 3 1.3 3 3-1.3 3-3 3z"></path>
        <path d="M8 10c2.8 0 5.1-1.5 6.9-4.6C13.1 2.5 10.8 1 8 1 5.2 1 3 2.4 1.2 5.4 2.9 8.6 5.2 10 8 10zM8 0c3.3 0 6 1.8 8.1 5.4C14 9.2 11.3 11 8 11S2 9.2 0 5.5C2 1.9 4.6 0 8 0z"></path>
      </svg>
  </button>
</div>

<div  data-text-input  class="bx--form-item bx--text-input-wrapper">
  <label for="text-input-7" class="bx--label bx--label--disabled">Text Input label</label>
  <input id="text-input-7" type="password" class="bx--text-input "
    placeholder="Placeholder text" data-toggle-password-visibility disabled>
  <button class="bx--text-input--password__visibility bx--tooltip__trigger bx--tooltip--icon__bottom" aria-label="Show password">
      <svg class="icon--visibility-off" hidden="true" width="16" height="16" viewBox="0 0 16 16">
        <path d="M11.846 3.45L15.293.007 16 .714l-3.284 3.281c1.261.902 2.377 2.212 3.347 3.93C14.02 11.642 11.333 13.5 8 13.5c-1.392 0-2.667-.324-3.822-.973L.703 16l-.706-.708 3.323-3.32C2.071 11.042.976 9.694.035 7.924 2.012 4.308 4.667 2.5 8 2.5c1.395 0 2.677.317 3.846.95zm-6.928 8.338c.944.477 1.97.712 3.082.712 2.795 0 5.076-1.483 6.907-4.568-.866-1.417-1.833-2.486-2.91-3.219l-1.55 1.55a3 3 0 0 1-4.185 4.182l-1.344 1.343zm-.882-.533l1.518-1.517A3 3 0 0 1 9.74 5.556l1.364-1.363A7.02 7.02 0 0 0 8 3.5c-2.798 0-5.047 1.439-6.819 4.432.842 1.465 1.792 2.568 2.855 3.323zm2.948-1.532a2 2 0 0 0 2.74-2.738l-2.74 2.738zm-.707-.707l2.74-2.738a2 2 0 0 0-2.74 2.738z"></path>
      </svg>
      <svg class="icon--visibility-on" width="16" height="16" viewBox="0 0 16 11">
        <path d="M8 7.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 1c-1.7 0-3-1.3-3-3s1.3-3 3-3 3 1.3 3 3-1.3 3-3 3z"></path>
        <path d="M8 10c2.8 0 5.1-1.5 6.9-4.6C13.1 2.5 10.8 1 8 1 5.2 1 3 2.4 1.2 5.4 2.9 8.6 5.2 10 8 10zM8 0c3.3 0 6 1.8 8.1 5.4C14 9.2 11.3 11 8 11S2 9.2 0 5.5C2 1.9 4.6 0 8 0z"></path>
      </svg>
  </button>
</div>

Text area

Validation message here
Optional helper text goes here

Vanilla JS

<!-- 
  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>
  <textarea id="text-area-2" class="bx--text-area bx--text-area--v2" rows="4" cols="50" placeholder="Placeholder text."></textarea>
</div>

<div class="bx--form-item">
  <label for="text-area-3" class="bx--label">Text Area label</label>
  <textarea data-invalid id="text-area-3" class="bx--text-area bx--text-area--v2" rows="4" cols="50" placeholder="Placeholder text."></textarea>
  <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>
  <textarea id="text-area-4" class="bx--text-area bx--text-area--v2" rows="4" cols="50" placeholder="Placeholder text."></textarea>
  <div class="bx--form__helper-text">
    Optional helper text goes here
  </div>
</div>

<div class="bx--form-item">
  <label for="text-area-5" class="bx--label bx--label--disabled">Text Area label</label>
  <textarea id="text-area-5" class="bx--text-area bx--text-area--v2" rows="4" cols="50" placeholder="Placeholder text." disabled></textarea>
</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 The selector to find the password visibility toggle
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