# Forms: The Shared Pattern for Collecting User Input Consistently

> Learn how a design system's form pattern combines fields, labels, help text, errors, and buttons so every form in a product works the same way.

**In short:** A form pattern in a design system combines fields, labels, help text, errors and buttons, so every form in a product collects input the same way.

From "Design systems", a free course by Venkat R. Murty: https://designervenkat.online/learn/design-systems/forms

## What you will learn

A form is the part of a product where a person gives information, such as an email address or delivery details. Sign-up pages, checkout pages, and account settings are all forms. A design system gives teams one shared way to build them. This lesson explains that shared way, which is called the form pattern.

In this course, Forms means the design system's reusable pattern for collecting user input. It shows how form fields, labels, help text, validation, and buttons are combined and laid out, so every form in a product looks and behaves the same way. By the end, you will be able to name the parts, describe the feedback states a field can show, explain how error messages should work, and list the accessibility checks a form guideline needs.

- **Form pattern:** A tested, shared recipe for one kind of task. Here, the recipe for collecting information from a person.
- **Input component:** One piece a person types into or chooses, such as a text box, a menu, or a checkbox.
- **Label:** The words that say what an input is for. It must stay visible on screen.
- **Helper text:** A short line of help shown before the person answers. Also called hint text.
- **Required marker:** A sign that tells people which answers must be given, or which are optional.
- **Validation:** A check that an answer is complete and can be used.
- **Inline error:** An error message placed right beside the field that has the problem.
- **Error summary:** A list of all the errors in a form, placed near the top of the page.
- **Primary action:** The main button that sends the form, such as Continue or Create account.
- **Screen reader:** Software that reads the screen out loud for people who cannot see it well.
- **Focus:** The field or button a person is currently using, often shown with an outline.
- **Read-only:** A field that shows a value the person can see but cannot change.
- **Disabled:** A field or button that is greyed out and cannot be used right now.

## What is the anatomy of a form pattern?

Picture a form pattern as a stack. Each question has a label at the top, then optional helper text, then the input itself. If something goes wrong, an error message appears in the same stack, between the helper text and the input. The questions run down one column, and one primary button closes the form. Because the order is fixed, a person who has used one form already knows where to look on the next.

### What are the five input parts?

- **Text field:** A box for a short typed answer, such as a name or an email address.
- **Select:** A closed menu where the person picks one option from a longer list, such as a country.
- **Checkbox:** A small square for yes or no, or for choosing several options at once.
- **Radio:** A round option where the person picks exactly one answer from a short group.
- **Toggle:** An on or off switch, usually for a setting that takes effect straight away.

A design system usually says which input suits which kind of question. The team then does not have to guess each time, and people meet the same control for the same job across the product.

### Labels, helper text, and required markers

Every input needs a label that stays visible. GOV.UK's rules place labels above their fields, keep them short, write them in sentence case, and leave off the colon at the end. Placeholder text, the faint example text inside an empty box, is not a label, because it disappears once the person starts typing. Long explanations belong on a separate page. For required markers, choose one style, either marking required answers or marking optional ones, and use it everywhere. Mixing the two confuses people.

> **Tip:** Write each label as the question the person is answering, in plain words. If the label is vague, such as Details, the person may not know what to type.

### Layout, spacing, and order

1. **Use one column:** Stack fields in a single column so the eye moves down the page.
2. **Group related fields:** When several inputs answer one question, such as an address, wrap them in a group with a legend. The legend is the group's title, and screen readers read it first.
3. **Keep the same gaps:** Use the same spacing between label, input, helper text, and message in every form. The exact measurements belong to other lessons on spacing and sizing.
4. **Reserve room for errors:** Leave space for an error message so the layout does not jump when one appears. A jumping page makes people lose their place.
5. **Order and finish:** Ask questions in the order people think about the task, and end with one primary button. Several competing main buttons make the next step unclear.

## What are the validation and feedback states?

A field is not one fixed picture. It changes as the person works with it. The pattern should name each state, so every designer draws it the same way. These are the states a form pattern usually covers.

- **Default:** The field as it looks before anyone touches it.
- **Focus:** The field the person is in right now. It needs a clear outline so keyboard users can see where they are.
- **Filled:** The field holds an answer. The answer should stay readable and easy to edit.
- **Error:** The answer failed a check. GOV.UK pairs a red message with a red border, so the message clearly belongs to its question.
- **Success:** The answer passed a check. Keep this state quiet, so the screen does not become noisy.
- **Disabled:** The field is greyed out and cannot be used right now. It should be clear why, or the person may think the form is broken.
- **Read-only:** The field shows a value the person can see but cannot change, such as an account number set by the system.

### When should an error appear?

The timing of errors is a rule that teams often disagree on, so the guideline must settle it. GOV.UK's validation pattern says not to check a field when the person leaves it. Instead, the check runs when they press the continue or submit button. It also warns against checking an answer before the person has finished typing, because slower typers get interrupted. PatternFly takes a different view, checking a field when focus leaves it. PatternFly also advises showing errors as close to the field as possible. Both approaches can work. The guideline should choose one default and name the exceptions.

Two more rules help. When errors are found after the page is sent, the page should reload with the problems shown inline. And an inline error should disappear once the field meets the rule.

> **Tip:** Accept reasonable answers. GOV.UK asks teams to accept postcodes with or without a space, and to ignore stray spaces and punctuation. Every rule you do not need is one error message fewer.

### How do you write an error message?

1. **Say what went wrong:** Name the problem in plain words. Vague text such as Invalid input tells the person nothing they can act on.
2. **Say how to fix it:** Give the next step. If the format matters, show a correct example, such as name@example.com.
3. **Reuse the label's words:** Use words from the question, so the person can match the message to the right field.
4. **Keep it calm:** People are often stressed when they make a mistake. Avoid blame and alarm, and use polite, plain sentences.
5. **Add, do not repeat:** Do not copy the helper text into the error. Add the missing detail instead.
6. **One message per field:** If several rules fail, show the one message most likely to fix the problem, not a stack of messages.

## How do you make forms accessible?

Accessibility means that every person can finish the form. That includes people who use only a keyboard, people who rely on a screen reader, and people who have trouble reading small text. A form guideline should make these needs part of the default, not an extra step for each team.

### Visible labels and keyboard use

- **Visible label:** Every field needs a label people can see on screen. A label that is hidden, or that exists only in the code, does not count.
- **Keyboard use:** A person must be able to reach every field, button, and error with a keyboard, and must always see where focus is.
- **Size and contrast:** Buttons should be large enough to tap easily.

### Linking errors to their fields

A screen reader user needs to hear which field has the problem. The error message must be tied to its input, so it is read out when the person reaches that field. GOV.UK places a hidden word, Error, before each message so that screen readers announce it clearly. When errors appear, GOV.UK also adds Error to the start of the page title and moves keyboard focus to the error summary.

## Worked example: a sign-up form

This example uses GOV.UK's email address pattern. It is one question, but it is built from the same parts as every other field in a well-made form. Follow it from top to bottom.

1. **The label:** The label Email address sits above the box, in sentence case, with no colon. It names exactly what the person is giving.
2. **The helper text:** Under the label, one short line explains why the address is needed: We will only use this to send you a receipt. GOV.UK asks teams to say what the address is for, so people feel safe giving it.
3. **The input:** A single-line box is wide enough to show at least 30 characters, so a long address stays visible while typing. Phones should show an email keyboard, spellcheck should be off, and pasting must work.
4. **The error state:** If the address breaks the format, the group shows the error state. A red border connects the message to its question. The message reads: Error: Enter an email address in the correct format, like name@example.com. The example shows the right shape, so the person knows what to change.
5. **The error summary:** At the top of the page, the summary repeats the same sentence and links to the email box. Focus moves there, so a keyboard or screen reader user hears the problem first.
6. **The primary action:** One primary button, such as Continue, sits below the field. The earlier answers stay in place, so the person only fixes the email and does not retype the form.

> **Tip:** Keep every answer after an error. Clearing the form forces people to start again. GOV.UK says not to clear fields when showing an error, so people can see what went wrong and edit it.

## How do you write the form guideline?

A pattern only helps if teams reuse it. The form guideline is the written rulebook that says how the pattern must be built. Without it, each team builds its own version, and the product slowly stops feeling like one product. A good guideline is short enough to read in one sitting, and specific enough that two designers would draw the same form.

### Do's and don'ts

- **Show errors in two places:** Do show the message beside the field and a summary at the top, both with the same wording.
- **Do not rely on colour alone:** A red field is not enough. The message itself must say what is wrong in words.
- **Do not use placeholder as the label:** Keep a visible label on every field, even when example text sits inside the box.
- **Do not rely on browser checks:** Turn off built-in browser validation and the required setting. Their messages cannot match the design system's look or wording.
- **Do not invent new controls:** If the pattern already has a select, a toggle, or a checkbox for the job, use it instead of building a new one.

> **Tip:** Write each rule as something a reader can check, such as: show the error beside the field and in the summary. Vague advice like keep errors friendly cannot be checked.

### What should the guideline specify?

A useful form guideline lists the approved inputs and when to use each one. It sets the label and helper text rules, names the feedback states, and says when errors appear. It gives the format for error messages, the place for the error summary, and the accessibility checks. Each rule should come with one correct example and one wrong example, so readers can see the difference.

## Quick check

Try these two short scenarios. Each one needs the ideas from this lesson to answer.

**Quick check:** A team's checkout form shows every error only in a red banner at the top of the page. Their profile form shows errors under each field, worded differently. Which form guideline would fix this, and what would it specify?

A. A colour guideline that picks a softer red for all banners, so both forms match visually.
B. A form guideline that says every form shows each error beside its field and in one summary at the top, with the same wording in both places.
C. A button guideline that moves the primary action to the top of every form, so people see it first.
D. A writing guideline that asks both forms to use shorter sentences, with no rule about where errors go.

**Answer:** B. The problem is where errors appear and how they are worded, not colour, buttons, or sentence length. A form guideline sets the placement and the matching wording, so both forms behave the same way.

**Quick check:** A user types a phone number with spaces and brackets, such as (020) 7946 0000. The form rejects it with the message Invalid input. The team wants a fix that follows the pattern. What should the rule say?

A. Reject any number that contains spaces, and keep the message Invalid input because it is short.
B. Ignore spaces, brackets, and other unwanted characters, and show a specific message only when the number still cannot be used.
C. Remove the helper text so the person knows the field is optional.

**Answer:** B. Good validation accepts reasonable formats and removes characters that do not change the meaning. When an answer still fails, the message must be specific and tell the person how to fix it.

## Sources

- [GOV.UK Design System: Error message](https://design-system.service.gov.uk/components/error-message/)
- [GOV.UK Design System: Recover from validation errors](https://design-system.service.gov.uk/patterns/validation/)
- [GOV.UK Design System: Email addresses](https://design-system.service.gov.uk/patterns/email-addresses/)
- [GOV.UK Design System: Fieldset](https://design-system.service.gov.uk/components/fieldset/)
- [GOV.UK Design System: Error summary](https://design-system.service.gov.uk/components/error-summary/)
- [GOV.UK Design System: Text input](https://design-system.service.gov.uk/components/text-input/)
- [GOV.UK Design System: Textarea](https://design-system.service.gov.uk/components/textarea/)
- [GOV.UK Design System: Question pages](https://design-system.service.gov.uk/patterns/question-pages/)
- [GOV.UK Design System: Select](https://design-system.service.gov.uk/components/select/)
- [GOV.UK Design System: Making labels and legends headings](https://design-system.service.gov.uk/get-started/labels-legends-headings/)
- [GOV.UK Design System error message discussion (GitHub)](https://github.com/alphagov/govuk-design-system/discussions/6065/)
- [Carbon Design System: Forms](https://www.carbondesignsystem.com/building-blocks/core/patterns/forms)
- [PatternFly: Form design guidelines](https://www.patternfly.org/components/forms/form/design-guidelines/)
- [Helsinki Design System: Form validation](https://hds.hel.fi/patterns/forms/form-validation/)
- [Form Validation Pattern (uxpatterns.dev)](https://uxpatterns.dev/patterns/forms/form-validation)
- [Home Office Design System: Error messages](https://design.homeoffice.gov.uk/accessibility/interactivity/error-messages)
- [Home Office Design System: Forms](https://design.homeoffice.gov.uk/accessibility/interactivity/forms)
- [CMS Design System: Error validation](https://design.cms.gov/patterns/Forms/error-validation/)
- [HashiCorp Helios: Form patterns](https://helios.hashicorp.design/patterns/form-patterns)
- [Cedar Design System: Error handling](https://cedar.rei.com/patterns/error-handling)
- [UK Department for Education: Design system considerations](https://accessibility.education.gov.uk/profession-guidance/interaction-design/design-system-considerations)
