Form elements
-
Select
Use select to let users choose an option from a long list but only use it as a last resort.
WCAG 2.2: Make sure that users can successfully use select without relying on click and drag movements (if you add functionality to select multiple options).
<div class="nhsuk-form-group">
<label class="nhsuk-label" for="select-1">
Label text goes here
</label>
<select class="nhsuk-select" id="select-1" name="select-1">
<option value="1">NHS.UK frontend option 1</option>
<option value="2" selected>NHS.UK frontend option 2</option>
<option value="3" disabled>NHS.UK frontend option 3</option>
</select>
</div>
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description.
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | false |
ID for the select box. Defaults to the value of name. |
| name | string | true | Name property for the select. |
| items | array | true | The items within the select component. |
| items[].value | string | false | Value for the option. If this is omitted, the value is taken from the text content of the option element. |
| items[].text | string | true | Text for the option item. |
| items[].selected | boolean | false |
Whether the option should be selected when the page loads. Takes precedence over the top-level value option. |
| items[].disabled | boolean | false | Sets the option item as disabled. |
| items[].attributes | object | false | HTML attributes (for example data attributes) to add to the option. |
| value | string | false |
Value for the option which should be selected. Use this as an alternative to setting the selected option on each individual item. |
| disabled | boolean | false |
If true, select box will be disabled. Use the disabled option on each individual item to only disable certain options. |
| describedBy | string | false |
One or more element IDs to add to the aria-describedby attribute, used to provide additional descriptive information for screenreader users. |
| label | object | true | The label used by the select component. |
| hint | object | false | Can be used to add a hint to the select component. |
| errorMessage | object | false |
Can be used to add an error message to the select component. The error message component will not display if you use a falsy value for errorMessage, for example false or null. |
| formGroup | object | false | Additional options for the form group containing the select component. |
| formGroup{}.classes | string | false | Classes to add to the form group (for example to show error state for the whole group). |
| formGroup{}.attributes | object | false | HTML attributes (for example data attributes) to add to the form group. |
| formGroup{}.beforeInput | object | false | Content to add before the select used by the select component. |
| formGroup{}.beforeInput{}.text | string | true |
Text to add before the select. If html is provided, the text option will be ignored. |
| formGroup{}.beforeInput{}.html | string | true |
HTML to add before the select. If html is provided, the text option will be ignored. |
| formGroup{}.afterInput | object | false | Content to add after the select used by the select component. |
| formGroup{}.afterInput{}.text | string | true |
Text to add after the select. If html is provided, the text option will be ignored. |
| formGroup{}.afterInput{}.html | string | true |
HTML to add after the select. If html is provided, the text option will be ignored. |
| classes | string | false | Classes to add to the select. |
| attributes | object | false | HTML attributes (for example data attributes) to add to the select. |
{% from 'select/macro.njk' import select %}
{{ select({
id: "select-1",
name: "select-1",
label: {
text: "Label text goes here"
},
items: [
{
value: 1,
text: "NHS.UK frontend option 1"
},
{
value: 2,
text: "NHS.UK frontend option 2",
selected: true
},
{
value: 3,
text: "NHS.UK frontend option 3",
disabled: true
}
]
}) }}
How to use select
The select component allows users to choose an option from a long list. Before using it, try other questions which will allow you to present users with fewer options. Consider using a different solution, such as radios.
Any input that's designed to let a user select multiple options must offer a way to do so without relying on click and drag movements or keyboard and mouse combination actions. This is to comply with WCAG 2.2 success criterion 2.5.7 Dragging Movements (W3C).
Research
User research shows that some users struggle with the select component, especially people who use a keyboard to navigate and people with motor difficulties. The dropdown feature makes users work hard to see and understand their options and click the option they want.
Known issues and gaps
Research shows that users can struggle with selects, particularly when users have:
- been unable to close the select
- tried to type into the select
- confused focused items with selected items
- tried to pinch zoom select options on smaller devices
- not understood that they can scroll down to see more items, or how to
Help us improve this guidance
Share insights or feedback and take part in the discussion. We use GitHub as a collaboration space. All the information on it is open to the public.
Feed back or share insights on GitHubRead more about how to feed back or share insights.
If you have any questions, get in touch with the service manual team.
Updated: August 2025