Skip to contentSkip to navigationSkip to topbar
Paste assistant Assistant
Figma
Star

Form Layout

Version 12.0.1GithubStorybook

A Form Layout groups related form elements that allow users to input information or configure options.

Guidelines

Guidelines page anchor

About Form Layout

About Form Layout page anchor

Use the Form Layout component to arrange a layout of form elements with preset spacing. Refer to our form pattern for additional guidance on types of forms and common form fields.

The different parts of the Form Layout component are:

  1. Form: renders an HTML form element and comes with default behavior from the browser (learn more about HTML form elements(link takes you to an external page)).
  2. FormControl: Contains form fields, which are the UI components where users enter information.
  3. FormControlTwoColumn: A group of two FormControls arranged horizontally.
  4. FormSection: A group of FormControls that renders an HTML fieldset.
  5. FormSectionHeading and FormSectionDescription: Use FormSectionHeading and FormSectionDescription to render a HTML legend which clearly describes the FormSection.
  6. FormActions: A group of buttons often with a primary Button ordered first, followed by a secondary Button.
  • Connect each form field to its associated Label with the htmlFor prop on the label, and the id prop on the input. Those two need to match.
  • If the form field has any associated Help Text, the field should also use the aria-describedby prop that equals the id of the help text. This ensures screen readers know the Help Text ties directly to the field.
  • Only use a single Form per page unless absolutely necessary. If using multiple Forms on a single page, take extra caution to ensure each form field's attributes are unique."
  • Don’t use CSS to control element order. Form Layout elements should be displayed in the same order in the HTML as they appear on screen, as screen readers announce form elements in the order they appear in the HTML. The order in which form elements are presented on a webpage should be logical and meaningful. Reference: WCAG(link takes you to an external page)
  • Don't ask for the same information twice in the same session. Reference: WCAG(link takes you to an external page)
  • Provide accessible error identification and messaging. Reference: WCAG(link takes you to an external page)
  • Group related fields using fieldsets and legends with FormSection and FormSectionHeading, which render an HTML fieldset and legend. Reference: WebAIM(link takes you to an external page)
  • Use a single column layout, as it can be more difficult for users with limited vision to scan from right to left if a multi-column layout is used.
(information)

Check accessibility for each form element component—for example, follow [Time Picker accessibility guidelines](https://paste.twilio.design/components/time-picker#accessibility). You can also refer to the [WCAG Forms Tutorial](https://www.w3.org/WAI/tutorials/forms/) for more details.


We recommend using single-column layouts for forms because they are easier to read. To learn more, check out this research on form readability(link takes you to an external page).

Use more than 1 column only when it is clearer than a single column and prevents users from inputting incorrect information. Reserve 2-column layouts for when form fields are organized as a coherent entity, like date ranges; first and last name; ZIP, city, and state; or credit card details.

Horizontal form field layout

Horizontal form field layout page anchor

Use a horizontal form field layout for Checkbox and Radio Groups when options can be placed next to each other in a logical order and the labels for each option are shorter than 3 words.

Form Layouts with sections

Form Layouts with sections page anchor

Complex forms should be split into sections, using FormSection which renders an HTML fieldset. When using multiple FormSections, place a Separator between them.

Optionally, each section can include a:

Use the maxWidth prop and a size token to set a max width on the form. When no max width is set, the form will be set to 100% of the parent container.

Ensure that field lengths provide both:

  • Meaningful affordances that help people answer questions
  • Enough room for inputs across multiple languages.

Designing a good form requires making decisions about composition, sequence, form elements, content, and feedback. Use the form pattern for further guidance on form order and organization.

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.

Do keep all the form elements left aligned. Avoid adding any left padding to the form fields or form actions.

Form Layout dos and don'ts

Form Layout dos and don'ts page anchor
Do

Use single column layouts as much as possible.

Don't

Avoid multi-column layouts unless form fields are organized as a coherent entity, like date ranges; first and last name; ZIP, city, and state; or credit card details

Do

Group related form elements into sections.

Don't

Don't present a form as one long, unorganized list of form fields.

Do

Implement the best field length needed for the customer.

Don't

Don’t implement a full-width form for every page. At the same time, don’t implement short form fields based only on the expected input length for one language. Consider the responsive behavior of the page and all supported languages.

Related Paste patterns and page templates page anchor