Components

Text Input

Text inputs enable users to enter free-form text data. You can use them for long and short-form entries.

Overview

Text inputs enable users to enter free-form text data. The type of text field used should reflect the length of the content you expect the user to enter. The default text input is for short, one-line content, whereas text area is for longer, multi-line entries.

Text input component

When to Use

  • A user needs to input unique information that cannot be predicted with a preset of options.
  • A user needs to input memorable data that can be entered more quickly in a free-hand format versus a more complex control.

When Not to Use

  • If a user can only enter an option from a predefined list then avoid using a free-form text input as it is likely to result in an error. Consider using a selection control such as a dropdown, select, or radio button group instead.

Variants

 VariantPurpose
Text Input

When the expected user input is a single line of text.

Text AreaWhen the expected user input is more than a few words that could span multiple lines.

Text Input

Use a text input when the expected user input is a single line of text. Text inputs have a fixed height and are used to enter simple free-form data entries with any combination of letters, numbers, or symbols.

Anatomy

Anatomy of the text input component
  1. Label: Text that informs the user about the content they need to enter in the field. It is required unless you get an approved accessibility exemption.
  2. Tooltip (optional): Use tooltips for explanatory or added information.
  3. Value: The content the user has entered into the field.
  4. Field: The container in which a user enters data. Must meet 3:1 non-text contrast requirements.
  5. Helper text (optional): Assistive text that can provide additional aid or context to the user. Often used to explain the correct data format. It is positioned below the field in the default style and surfaced through a tooltip in the fluid style.

Text Area

Use a text area when the expected user input is more than a few words and could span multiple lines. It is commonly used for features like user commentary or descriptions. It supports all the same states and functionality as text input except for the password functionality. Text area has several unique functionalities not included in the text input, like the resize handle and character counter.

Anatomy

Anatomy of the text area component
  1. Label: Text that informs the user about the content they need to enter in the field. It is required unless you get an approved accessibility exemption.
  2. Optional versus required indicator (optional): This label indicates if the field is optional or required for the user to complete.
  3. Character counter (optional): Indicate the number of characters being entered and the total number of characters allowed.
  4. Value: The content the user has entered into the field.
  5. Field: The container in which a user enters data. Must meet 3:1 non-text contrast requirements.
  6. Helper text (optional): Assistive text that can provide additional aid or context to the user. Often used to explain the correct data format. It is positioned below the field in the default style and surfaced through a tooltip in the fluid style.

Resize Handle

The resize handle is included by default in the text area component. It allows a user to manipulate the field height by making it longer or shorter. The resize handle has no effect on the width of the text area container, it only affects the height. If the user makes the field size shorter than the content inside the field then a vertical scroll will become available.

 

Formatting

Alignment

Input labels should vertically align to the grid and with other type elements on the page. The alignment of the input container will differ based on the style of text input you are using.

Content

Overflow Content

Overflow in a text input

If a user’s content is unexpectedly too long for the single line of a text input then the value content can horizontally scroll inside the field container when moving the cursor from one end of the value to the other.

Overflow in a text area

If a user’s content exceeds the vertical space of the variable text area then a user can either expand the field container using the resize handle or they can vertically scroll the content inside the set field container.

Modifiers

Password Input

Password input is a sub-variant of text input. It is used to collect private data and will hide the characters as a user enters them. A user can choose to toggle on the character visibility by clicking the view icon on the far right of the input field. When using a password input, be sure to provide detailed helper text listing any requirements related to the data format, such as types of characters allowed or data structure.

Password input modifier component

Character Counter

A character counter can be added to text area to indicate both the number of characters being entered and the total number of characters allowed. Once the max number of characters is reached, the text area should prevent the user from entering any additional characters.

Character counter modifier component