Component | +When to use | +
---|---|
Arranges a layout of form elements with preset spacing. | +|
Explains the purpose of the form or form section. | +|
Provides a visible and accessible name to a form field. | +|
Helps users prevent an error and describe what makes the form field successful. It also includes error, warning, and success variants to communicate different states on a field. | +|
Triggers actions and submits forms. | +|
Summarizes errors or other important information in the header. | +
Component | +When to use | +
---|---|
Use Input for single-line text input and Textarea for multi-line text input. | +|
Use a Checkbox to enable binary choices that require a submit action. Use a Switch for immediate binary on/off choices that don’t require a submit action and applies the user's choice instantly. |
+ |
Allows the user to upload only one file at a time. | +|
Allows the user to upload multiple files. | +
Component | +When to use | +
---|---|
Use for up to 6 fixed list items and when only one selection is allowed. | +|
Use for 6+ fixed list items and when only one selection is allowed. By default, use Select. | +|
Use for lists with 15+ options or when users need to search a database to select one option. | +
Component | +When to use | +
---|---|
Use for up to 6 fixed list items and when multiple selection is allowed. | +|
Use for 6+ fixed list items and when multiple selection is allowed. | +|
Use when you’re editing a collection of data within a form. | +
Component | +When to use | +
---|---|
Use it when the exact value doesn’t matter. | +|
Use it when the exact numeric value matters. | +|
Use it for selecting specific dates. | +|
Use it for selecting date ranges. | +|
Use it for selecting specific times. | +|
Use it for selecting time ranges. | +
++ +Don’t make the user repeat information. For example, if the shipping and billing addresses are the same, provide an option to reuse the shipping address instead of requiring duplicate input. + +### Form order + +#### Order form fields logically + +When ordering your form, place fields in a logical order from a user’s perspective, not the application or database’s logic. For example, it’s unusual to ask for someone’s address before their name. + ++ Each question in a Web form has a cost…If there are too many questions in the form, you’ll lose users…if there are questions in the form that users consider impertinent or irrelevant—or, even worse, you’ll get made-up data. + ++
++ + +#### Organization: When to break into sections or new pages + +After determining the number of form fields, decide how to group them into sections, using `FormSection` from the [Form layout component](/components/form). If a form naturally breaks down into short sections, a [single step form](https://docs.google.com/document/d/1sYcP_i_YTwYWWdjKDQfkIdMj1NqyZV5c_8k4BxrEYc0/edit?pli=1&tab=t.0#heading=h.3vpocpbk0gl7) is likely to be a good way to organize the form. When a form becomes long and has more than 8 questions that are only related by a few topics, [multi-step form](https://docs.google.com/document/d/1sYcP_i_YTwYWWdjKDQfkIdMj1NqyZV5c_8k4BxrEYc0/edit?pli=1&tab=t.0#heading=h.yi4naptd6s8d) would be a better way to organize the form. + +### Form field composition + +#### Alignment + +Keep forms left-aligned to improve scannability and help users quickly understand the required information. This also makes it easier for keyboard users to tab through fields. + +#### Field length + +Ensure that field lengths provide both: + ++ The order of questions in your form should, as closely as possible, match the way things flow in the user’s mind. + ++