Label
Says what to enter. A red * when required, or “(optional)”.
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
As it appears on your ID
Form field
Usage
<div class="nds-text-input"> <div class="nds-text-input__label-row"> <label class="nds-text-input__label" for="first-name"> First name </label> <span class="nds-text-input__required" aria-hidden="true"> * </span> </div> <div class="nds-text-input__control-wrap"> <input class="nds-text-input__control" type="text" id="first-name" name="first-name" aria-describedby="first-name-hint" value="Ada" autocomplete="given-name" required /> </div> <p class="nds-text-input__hint" id="first-name-hint"> As it appears on your ID </p></div> WordPress
<!-- wp:nds/text-input {"type":"text"} --><div class="nds-text-input"> <div class="nds-text-input__label-row"> <label class="nds-text-input__label" for="first-name"> First name </label> <span class="nds-text-input__required" aria-hidden="true"> * </span> </div> <div class="nds-text-input__control-wrap"> <input class="nds-text-input__control" type="text" id="first-name" name="first-name" aria-describedby="first-name-hint" value="Ada" autocomplete="given-name" required /> </div> <p class="nds-text-input__hint" id="first-name-hint"> As it appears on your ID </p></div><!-- /wp:nds/text-input --> Usage
// Import the componentimport { TextInput } from "@nigerian-design-standards/react";// Use it<TextInput label="First name" hint="As it appears on your ID" value="Ada" required/> Usage
// Import the componentuse NDS\Components\TextInput;// Use itecho TextInput::render([ 'label' => 'First name', 'hint' => 'As it appears on your ID', 'required' => true,]); 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.
Each part is its own component. The field components already include them.
Says what to enter. A red * when required, or “(optional)”.
As it appears on your ID
Help most people need. Body/small in text/secondary.
Error: Enter your first name
Icon and text in status/error/surface. Takes the hint’s place.
The question for a group. Headline/small when it is the page’s only question.
The properties every field shares. The same in HTML, WordPress and React.
| Property | Type | Possible values | Description |
|---|---|---|---|
| label | string | any text | Required. What to enter, in a few words. No colon. |
| required | boolean |
|
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.
| 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 | — |
As it appears on your ID
Keep the label above the field, and add a hint only when people need it.
Don’t show * and “(optional)” on the same field. Required gets *, optional says so.
How the parts sit around a field.
How to write labels, hints and errors.
A format or where to find a number, not the label again.
“Enter your first name”, not “This field is required”.
Required gets *, optional says “(optional)”. Never both.
The error under the field matches the error summary.
| 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. |
Every visible relationship has one in code too, so screen reader users don’t lose it.
| 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. |
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
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.
Is this page useful?