Skip to content

Forms: text input

ShannonTucker edited this page Mar 25, 2022 · 4 revisions
  • Text inputs allow users to enter information.
  • Text inputs can be accompanied by information pop-ups (naming) and error messages.
  • Please see the form template to get started with creating your own forms and error messages.

Overview

Desktop and mobile form input component

Labels

There are 2 types of labels.

1. A label indicating a required input field

required label

2. A label indicating an optional input field

Optional label

Input fields

There are 2 types of input fields.

1. Text input field (one line)

  • For short text inputs that do not go past one line
  • For desktop there are 6 widths to choose from
  • For mobile there are 2 widths to choose from
  • Each variation has a focused/active state as well

Desktop text input fields

browser text input field

Mobile text input fields

mobile text input field

2. Text area field (more than one line)

  • For longer text inputs that go past one line
  • For desktop there are 3 widths to choose from
  • For mobile there is 1 width only
  • Each variation has a focused/active state as well

Desktop text area fields

browser text area field

Mobile text area fields

mobile text area field

Usage

When to use

  • In forms or dialogs
  • Anywhere a user would need to type in information

How to use

Labels

  • On desktop, labels can span 8 columns long (~60 characters with no spaces) or less, regardless of the width of the input field

Help text

  • Help text can be used to assist users and should be kept to two sentences or less.

Input fields

  • Select an input field width based on the estimated length of the user's response (the input field width provides a hint to users as to how much text to write)
    • For desktop input widths spanning 4, 5, or 6 columns, use 2 columns on mobile
    • For desktop input widths spanning 1, 2, or 3 columns, use 1 column on mobile
  • When a user needs to write paragraphs of text, use a text area field
  • Use one input field (rather than multiple fields) for numbers that have multiple sections (e.g., phone numbers, Social Security Numbers, or credit card numbers)

Form layout

  • Use a horizontal layout (a single column) for your text input fields so users can read the form in a straight line down the page
    • The exception to this is when using 2 smaller width input fields that are related to each other, such as credit card expiry date and security code

Customizing text input fields

Text inside the input field

  • For text fields (one-line fields), the text in the field can be removed by deleting the text, rather than deleting the text layer
  • For text areas (multi-line fields), the text in the field can be hidden by changing the text color to white
    • Don't delete the text, as the size of the input area will decrease as well
  • For text areas, the text field contains 400 characters without spacing - this can be adjusted to your needs by replacing the text with the desired amount of characters

Colours

  • The colours used in the input field component should not be changed (except for the input text changing to white to hide it, as mentioned above)

Labels

  • When adding a label with a long character count, you can break up the text into 2+ lines by hitting the enter key

Examples

Desktop

desktop form example

Mobile

mobile form example

How we created this component - 4A Assessment

We added the text input component to the Extended GC Design library - DECD as it did not exist in the Canada.ca design system. We conducted research on best practices and designed with accessibility at the forefront.

Clone this wiki locally