Skip to content

Official government website An official website of the Federal Government of Nigeria

How you know
Federal Ministry of Communications, Innovation & Digital Economy Nigerian Design Standards

Form field

The parts around every question: a label, an optional hint, an error message after a failed submit, and a legend for groups. They look and behave the same on every field.

Updated

Live example

Form field

As it appears on your ID

Controls
Property Control What it does
What to enter, in a few words
Required
Adds a red *. Off shows “(optional)”
Help most people need to answer

Overview

Every question has a label. Add a hint only when most people need help, and show an error only after a submit fails: it takes the hint’s place, below the control.

Use these parts for

  • A label on every field, always visible
  • A hint with a format, where to find a number, or why we ask
  • A legend that asks the question for a group

Don’t use

  • Placeholder text instead of a label
  • Errors before people have answered
  • A legend for a single field (its label does that)

Parts

Each part is its own component. The field components already include them.

First name

Label

Says what to enter. A red * when required, or “(optional)”.

As it appears on your ID

Hint

Help most people need. Body/small in text/secondary.

Error message

Icon and text in status/error/surface. Takes the hint’s place.

How would you like to be contacted?

Legend

The question for a group. Headline/small when it is the page’s only question.

Specifications

The properties every field shares. The same in HTML, WordPress and React.

Form field properties
Property Type Possible values Description
label string any text Required. What to enter, in a few words. No colon.
required boolean
  • true default
  • false
Adds a red * (hidden from screen readers) and the required attribute. False shows “(optional)”.
hint string any text Optional. Linked to the field with aria-describedby.
error string any text Shown after a failed submit, in place of the hint. Adds aria-invalid and a hidden “Error:”.

In code, the label’s for matches the input’s id. The input gets aria-describedby with the hint and error ids, and aria-invalid="true" in an error. For groups, use a <fieldset> with a <legend> and put the ids on the fieldset.

Tokens

Form field tokens and contrast
Part Token Contrast on the page
Label Body/medium-emphasized · text/secondary 6.6:1
Required * status/error/surface, 4px after the label (spacing/050). Hidden from screen readers 4.9:1
“(optional)” Body/medium · text/secondary 6.6:1
Hint Body/small · text/secondary 6.6:1
Error message icon/error 20px · Body/small-emphasized · status/error/surface 4.9:1
Legend Title/small · text/primary (Headline/small as a page heading) 17.6:1
Spacing spacing/100 8px inside a field · spacing/300 24px in a fieldset · spacing/400 32px between fields —

Use cases

Do

As it appears on your ID

Keep the label above the field, and add a hint only when people need it.

Don’t

First name (optional)

Don’t show * and “(optional)” on the same field. Required gets *, optional says so.

Layout

How the parts sit around a field.

Label, control, message
The order never changes. The hint or the error sits below the control.
8px inside a field
spacing/100 between the label, the control and the hint or error.
32px between fields
spacing/400 between questions; 24px (spacing/300) inside a fieldset.
Required note
“Fields marked * are required” under the heading of any form with required fields.
16px typed text
Body/medium in fields on every screen, so phones don’t zoom in. Hints and errors are 14px.

Copywriting

How to write labels, hints and errors.

Short labels
“First name”, not “Please enter your first name:”.
No colons
Labels don’t end with a colon.
Hints help, not repeat

A format or where to find a number, not the label again.

Errors say how to fix

“Enter your first name”, not “This field is required”.

Required or optional

Required gets *, optional says “(optional)”. Never both.

Same words in the summary

The error under the field matches the error summary.

Examples

Form field copywriting examples
Write Don’t write Why
First name Please enter your first name: Short, no colon.
Like 0803 123 4567 Enter your phone number Shows the format, not the label again.
Enter your first name This field is required Says how to fix it.
Email address (optional) Email address * (optional) Never both.
Date of birth must be in the past Invalid date Says what is wrong.

Accessibility

Every visible relationship has one in code too, so screen reader users don’t lose it.

Keyboard interaction for form fields
Key What it does
Tab Moves to the field. Labels and legends aren’t Tab stops.
Shift + Tab Moves back.
Click a label Moves focus to its field, or ticks a checkbox or radio.
  • The label’s for matches the input’s id, and its visible text is the accessible name (WCAG 1.3.1, 2.5.3).
  • The hint and error are linked with aria-describedby (WCAG 1.3.1, 3.3.2).
  • Errors start with a hidden “Error:”, set aria-invalid, and use an icon and text (WCAG 3.3.1, 1.4.1).
  • The * is hidden from screen readers; the input has the required attribute (WCAG 3.3.2).
  • Label and hint 6.6:1, error 4.9:1, legend 17.6:1 (WCAG 1.4.3).

For developers

Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.

For designers

Use Form/Label, Form/Hint, Form/Error message, Form/Legend and Form/Required note from 01 Library – Foundations. The field components already include them. Don’t detach them.

References

Feedback

Report a problem with this page