Select
A native select for about 7 to 15 known options. The first option, 'Select a state', has no value.
Lets people pick one option from a list, such as state, local government area or service category.
Updated
Where you live, so we can send your message to the right office.
Select
Usage
<div class="nds-select"> <div class="nds-select__label-row"> <label class="nds-select__label" id="state-label" for="state"> State </label> <span class="nds-select__required" aria-hidden="true"> * </span> </div> <div class="nds-select__control-wrap"> <select class="nds-select__control" id="state" name="state" required aria-describedby="state-hint" > <option value=""> Select a state </option> <option value="lagos" selected> Lagos </option> <option value="abuja"> Federal Capital Territory </option> <option value="kano"> Kano </option> <option value="rivers"> Rivers </option> </select> <span class="nds-select__icon" aria-hidden="true"> <svg class="nds-select__icon-svg" focusable="false"> <use href="#nds-icon-caret"> </use> </svg> </span> </div> <p class="nds-select__hint" id="state-hint"> Where you live, so we can send your message to the right office. </p></div> WordPress
<!-- wp:nds/select {"label":"State"} --><div class="nds-select"> <div class="nds-select__label-row"> <label class="nds-select__label" id="state-label" for="state"> State </label> <span class="nds-select__required" aria-hidden="true"> * </span> </div> <div class="nds-select__control-wrap"> <select class="nds-select__control" id="state" name="state" required aria-describedby="state-hint" > <option value=""> Select a state </option> <option value="lagos" selected> Lagos </option> <option value="abuja"> Federal Capital Territory </option> <option value="kano"> Kano </option> <option value="rivers"> Rivers </option> </select> <span class="nds-select__icon" aria-hidden="true"> <svg class="nds-select__icon-svg" focusable="false"> <use href="#nds-icon-caret"> </use> </svg> </span> </div> <p class="nds-select__hint" id="state-hint"> Where you live, so we can send your message to the right office. </p></div><!-- /wp:nds/select --> Usage
// Import the componentimport { Select } from "@nigerian-design-standards/react";// Use it<Select label="State" hint="Where you live, so we can send your message to the right office." required/> Usage
// Import the componentuse NDS\Components\Select;// Use itecho Select::render([ 'label' => 'State', 'hint' => 'Where you live, so we can send your message to the right office.', 'required' => true,]); Use a select for a short list people can scan in a native menu. For long lists people type to filter, use the Combo box. Every field has a visible label, and a hint only when most people need help to answer.
A native select for about 7 to 15 known options. The first option, 'Select a state', has no value.
On desktop the browser opens a list like this. On phones the phone opens its own picker.
The properties of Form/Select field and Form/Combo box. The same in HTML, WordPress and React.
| Property | Type | Possible values | Description |
|---|---|---|---|
| select · state | string |
| Active is the field in use: a 2px border/dark (not the keyboard focus ring). Open shows the list. On phones, the native OS picker opens. Error shows the message and a red border. |
| required | boolean |
|
Shows an asterisk in the label row and sets the native required attribute on
the control. Use optional text beside the label when the field is not mandatory.
|
| options | array | label + value | The list of choices. The first option is “Select a …” with no value so it fails validation until someone picks. |
In code, use a native <select> with <label for>. For long
filterable lists, see the Combo box page.
| Part | Token | Contrast on the page |
|---|---|---|
| Field border | border/strong, 1px · border/dark, 2px when active | 4.2:1 · 14.3:1 |
| Error border | status/error/surface | 4.9:1 |
| Menu | surface/canvas · border/default · radius/050 · header band surface/muted + divider | — |
| Option | spacing/500 (40px tall) · border/dark 2px on keyboard focus | 14.3:1 |
| Chosen option | Semi bold · action/primary/default check icon | 5.8:1 |
| Scrollbar thumb | text/muted on surface/muted | 6.1:1 |
Use a select for about 7 to 15 known options people can scan in a menu.
Don’t use a select for yes or no. Two radios are quicker and show both answers at once.
How the field and its menu are sized and placed.
How to write the label, the options and the messages.
“State”, “Topic”, “Local government area”.
The first select option has no value: “Select a state”.
Alphabetical for states and LGAs. Most common first only when you have evidence.
A few words each, so the menu is easy to scan.
“Select the state you live in”, not “Invalid selection”.
“No matches for ‘Ikx’. Check the spelling, or type fewer letters.”
| Write | Don’t write | Why |
|---|---|---|
| Select a state | -- Please select -- | Says what to do in plain words. |
| Select the state you live in | Invalid selection | Says how to fix it. |
| No matches for "Ikx" | No data | Says what happened and what to try. |
| Local government area | LGA (select one) | Spells it out; the field shows it’s one choice. |
| Abia, Adamawa, Akwa Ibom … | Lagos, Abuja, then the rest | Alphabetical, so people can find their state. |
Selects use native <select> and <option> elements. Combo boxes
follow the WAI-ARIA combobox pattern with a visible <label>.
| Key | What it does |
|---|---|
| Space or Alt + ↓ | Opens the list. |
| ↑ / ↓ | Moves through options. |
| Enter | Selects the option and closes the list. |
| Esc | Closes the list. On a combo box, Esc again clears the text. |
| Typing | Select: jumps to the first option starting with that letter. Combo box: filters the list. |
| Tab | Closes the list and moves to the next field. |
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
Use Form/Select field and Form/Combo box from 01 Library – Foundations. Don’t detach them.
Is this page useful?