Forms

One of the most important type of interaction for clients using our products. Don't just put together a form, design it.

UsageOverview

Forms can be one of the most important user patterns in our products. They help users complete tasks, configure system settings and most importantly, handle registration, purchasing, and support flows.

How to use

General considerations when using forms:


AnatomyWriting & Tone

Use “we,” “our” and “you” to create a sense that we are speaking directly to our customers.

Elements

Some of the most common form elements:

1 - Header

Including straightforward headers help users understand the overall purpose of a form.

2 - Labels

Labels inform the user of the meaning of the corresponding input. Use short, clear text for labels.

3 - Input fields

Don't just put together with input fields, design the form to ask only what is really needed, conversion rate is affected with every input field that is added to the form.

Clearly label required fields so as to avoid user trial and error.

[Input field guidelines (WIP)]

4 - Selection controls

5 - Buttons

Buttons should generally be placed in order of importance from right to left. Primary buttons should be placed on the right while secondary buttons on the left.

Exceptions to this rule include:

6 - Links

Forms commonly require actions other than a simple submission. In some cases, these actions should be performed by buttons and in others, by links:


BehaviorFocus

When presenting a form on a screen or a modal, always set the state of the first input element to focus.

Validation & Errors

Don't make validation too strict.

Indicate success by including a visual notification in the resulting view. This can be a dismissable inline alert or a toast notification.

When a view does include a form with error fields, an alert should be visible at the top of the view with a generic error message. Do not list individual field errors in this message. Specify these errors by styling each invalid input. Be consistent with the placement and styling of these types of messages.

Javascript validation

Error messages Loading

Multi-step forms or forms utilizing progressive disclosure to lessen the impact of a long-form should include a loading sequence between steps in the case of encountering server wait time.

Keyboard

Users should be able to focus on and edit every field in the form using only the keyboard. Tab index should be documented for every form sent to development.


Order & Alignment

Order a form logically from a user's perspective rather than from the application or database's perspective. Asking a user for their state before their country of residence would be unusual.

Forms should always be left-aligned except on smaller containers or as a result of a responsive breakpoint when they would expand to 100% width.


Best Practices Responsive Design Accessibility

As with all elements, practice accessible coding techniques with form fields, field-sets, and buttons.

Placeholder text is considered bad for accessibility because:

Resources


Feedback

We would like to get your feedback. Tell us how you use this component in your projects and how we can improve it.

StyleInput Field

This example is not to scale. Click to inspect.

Selection Controls

CodeGuidelines

Where appropriate, use HTML5 input types to ensure ease of use, particularly on touch devices. The email input type is especially useful in mobile browsers, but all types to consider include:

*Note: On mobile devices, tel type puts the user into the number keypad rather than the regular keyboard. Use tel as the preferred type when coding a numbers-only input.

Use the following types with caution, as the implementation in some (or all) browsers may be confusing and vary dramatically in presentation:

All major browsers support the number input, but display may vary. Because several browsers include some kind of spinner UI (up/down arrows to increment the input), some users may be confused by the type of field, while others are familiar with it. To mitigate this problem, you can use input attributes and browser-specific styling in your implementation, or consider an alternate input, such as tel.

Submit events

Forms should generally be executed with input elements of type="submit". Use this tag rather than <input type="button">.

Attach all JavaScript triggers to form and field events, however, rather than click events of a button or link. The allows users to submit forms or tab through form fields with keys, within a touch device keyboard, or by other methods (especially those used by accessibility browsers); attaching events to form submits circumvents problems that may arise from any alternate input scenario.

JavaScript validation

In most cases, JavaScript validation is not necessary. Some situations may make client-side validation more useful to the user, however.

You may potentially want to use client-side validation when:

While client-side validation is often an expedient and helpful pattern, consider certain drawbacks:

Best practices Textbox
TextArea
Checkbox
Radio