Skip to main content Intelligence Community Design System ICDS Get started Accessibility Styles Components Patterns Community
Skip to page content Show navigation section

Text field

Guidance Code Accessibility

Component variants

There are two types of text field:

  • Single line text fields

  • Multi-line text fields (also known as text areas)

Text fields

Use text fields for entering and editing single lines of text.

Interactive example

Text areas

Use text areas for entering and editing large amounts of text that require more than a single line.

Interactive example

When to use

Use text fields as part of a form or other data collection page for capturing text input.

Content

Labels

Use clear labels to indicate what information should be entered into the field.

Helper text

Use helper text in addition to the field label when additional information helps users understand what information is required.

A text field component with a label and helper text.
A text field with helper text.

When setting minimum and maximum values using themin andmax props, make sure to add an indication of these formatting rules in the helper text.

Placeholder text

Use placeholder text to optionally provide an example of what to type into the field.

Only use placeholder text if it makes it easier to fill in the text field.

Don't use placeholder text to convey additional meaning other than an example of the expected input.

An image showing two text fields, both with a label which states 'Email'. One shows a placeholder email in the input box, while the other shows a filled in input box with an actual email address.
A text field with an example of placeholder text and user-inputted text.

Icons

When including an icon in a text input make sure that the icon is understandable and relevant to the type of input required by the field. Always provide alternative descriptions for icons. Don't use icons if they aren't necessary.

An image showing two text fields. The top one titled 'Username' features an icon of a person, and the field titled 'Password' features an icon of a lock. Use understandable visual icons to add clarity to the field and draw attention.
An image showing two text fields. The top one titled 'Username' features an icon of a telephone, and the field titled 'Password' features an icon of a dog paw. Incorrect use of icons can cause confusion.

Character count

Include a character limit and counter to show how close the current input is to the maximum input length.

An example of two text areas with a character count. The first is below the character count, and the second is over the character count and is showing an error.
Use a character count to clearly inform users of the character limit.

Layout and placement

Field width

Make the width of the field reflect the length of content you expect the user to enter.

An image showing three text fields. The top two, titled 'First name' and 'Second name' take up half the horizontal size of the third one, titled 'Address'.
Three text fields correctly sized to the expected length of input.
An image showing three text fields. The top two, titled 'First name' and 'Second name' are the same horizontal size of the third one, titled 'Address'.
Three text fields not correctly sized to expected content.

Validation (error handling)

Real-time validation helps the user streamline their process and efficiently complete a form. All error validation should be accompanied by an error label. Use inline validation for successes that don't require success labels.

An image showing three different text fields with different validation states. The first one shows an success validation message. The second one shows a warning validation message. The third one shows an error validation message.
Text fields showing the three different validation states.
A text field labelled 'Favourite hot drink', with a green tick icon within the input field to show the successful validation state. Use inline validation for successes that don't require success labels.

Last reviewed 25 April 2023 .
Navigated to Text field - Intelligence Community Design System