Text Fields

Text fields allow users to enter and edit text.

Supported Input Types

This control supports the following input types + <textarea>:

  • <input type="date">
  • <input type="datetime-local">
  • <input type="email">
  • <input type="file">
  • <input type="hidden">
  • <input type="month">
  • <input type="number">
  • <input type="password">
  • <input type="search">
  • <input type="tel">
  • <input type="text">
  • <input type="time">
  • <input type="url">
  • <input type="week">

Attributes such as disabled and readonly are also supported, but require additional classes for full styling to be applied. Review the following demos for these scenarios.

Note: For date and time related fields, review Pickers.

Basic Text Fields

The helper text is optional, but if used, note the use of aria-describedby on the input which references the id of the helper text element.

Textareas

Textareas require that the following classes be placed on a wrapping div:

.u-textfield .u-textfield--textarea

Input Types

Showcasing a few common types of input fields, review the supported input types.

Note: Review browser support before choosing a native HTML5 input type without backup masking or validation.

Input Adornments

An input adornment can be used to add a prefix, a suffix or an action to an input.

Error State

To display field in an error state, add .u-form-control--invalid to the .u-form-control element, and .u-form-helpertext--invalid to the helper text element (if in use).

Note: Implementation of validation logic is up to the application.

Properties