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.

Experimental 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>

Experimental 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