Stacked
Fields 24px apart, on every screen. Names vary in length.
Asks one question in several fields, like a person’s name in First, Middle and Last name parts.
Updated
Input group
<fieldset class="nds-input-group" aria-describedby="docs-input-group-live-hint"> <legend class="nds-input-group__legend"> Your name </legend> <p class="nds-input-group__hint" id="docs-input-group-live-hint"> As it appears on your NIN slip </p> <div class="nds-input-group__fields"> <div class="nds-text-input"> <div class="nds-text-input__label-row"> <label class="nds-text-input__label" for="docs-input-group-live-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="docs-input-group-live-first-name" name="first-name" value="Ada" autocomplete="given-name" required /> </div> </div> <div class="nds-text-input"> <div class="nds-text-input__label-row"> <label class="nds-text-input__label" for="docs-input-group-live-middle-name"> Middle name </label> <span class="nds-text-input__optional"> (optional) </span> </div> <div class="nds-text-input__control-wrap"> <input class="nds-text-input__control" type="text" id="docs-input-group-live-middle-name" name="middle-name" autocomplete="additional-name" /> </div> </div> <div class="nds-text-input"> <div class="nds-text-input__label-row"> <label class="nds-text-input__label" for="docs-input-group-live-last-name"> Last 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="docs-input-group-live-last-name" name="last-name" autocomplete="family-name" required /> </div> </div> </div></fieldset> An input group wraps related fields in a fieldset, with one legend for the question. Each field keeps its own label and its own error.
Stacked is the one to use. Row is in Figma for short parts, but names always stack.
Fields 24px apart, on every screen. Names vary in length.
In Figma for short parts. Not used for names.
The field that needs fixing shows its own error message.
The properties of Form/Input group. The same in HTML, WordPress and React.
| Property | Type | Possible values | Description |
|---|---|---|---|
| legend | string |
| The question. No asterisk: each field marks itself. |
| direction | string |
| Stacked on every screen size for names. |
| error | boolean |
| Shows the error on the field that needs fixing. |
| fields | array |
| The parts, each with its own label. |
In code, use <fieldset> with a <legend>, and aria-describedby for the hint. Name fields use autocomplete given-name, additional-name and family-name.
| Part | Token | Contrast on the page |
|---|---|---|
| Legend | text/primary | 17.6:1 |
| Gap between fields | spacing/300 (24px) | — |
| Field border | border/strong, 1px | 4.2:1 |
| Border in an error | status/error/surface, 1px | 4.9:1 |
Ask for First, Middle (optional) and Last name, each with its own label.
Don’t squeeze name fields into one row. Long names get cut off.
How the group sits on a form.
How to write the legend, labels and errors.
“What is your name?” or “Your name”.
First name, Middle name (optional), Last name.
“Enter your last name”, not “Name is invalid”.
| Write | Don’t write | Why |
|---|---|---|
| First name · Last name | Full name | Official forms ask for names in parts. |
| Middle name (optional) | Middle name* | Says it can be left blank. |
| Enter your last name | Name is invalid | Says which part to fix. |
A fieldset and legend tell screen readers the fields belong to one question.
| Key | What it does |
|---|---|
| Tab | Moves to the next field in the group. |
| Shift+Tab | Moves back to the previous field. |
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
Use Input group from the NDS Website documentation frames. Match node 900:181239 for variants, tokens and copy.
Is this page useful?