Skip to main content

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).

Open this default select example in a new tab
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="sort-by">
    Sort by
  </label>
  <select class="nhsuk-select" id="sort-by" name="sortBy">
    <option value="recently-published" selected>Recently published</option>
    <option value="recently-updated">Recently updated</option>
    <option value="most-views">Most views</option>
    <option value="most-comments">Most comments</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.

Nunjucks arguments for default select
Name Type Required Description
id string false ID for the select box. Defaults to the value of name.
name string true The name attribute for the select.
items array true The items within the select component.
items[].value string false The value attribute 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[].divider boolean false Divider line used to separate option items.
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 The 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.
inputWrapper object false If any of formGroup.beforeInput or formGroup.afterInput have a value, a wrapping element is added around the select and inserted content. This object allows you to customise that wrapping element.
inputWrapper{}.classes string false Classes to add to the wrapping element.
inputWrapper{}.attributes object false HTML attributes (for example data attributes) to add to the wrapping element.
attributes object false HTML attributes (for example data attributes) to add to the select.
{% from "select/macro.njk" import select %}

{{ select({
  label: {
    text: "Sort by"
  },
  id: "sort-by",
  name: "sortBy",
  value: "recently-published",
  items: [
    {
      value: "recently-published",
      text: "Recently published"
    },
    {
      value: "recently-updated",
      text: "Recently updated"
    },
    {
      value: "most-views",
      text: "Most views"
    },
    {
      value: "most-comments",
      text: "Most comments"
    }
  ]
}) }}

When to use select

The select component should only be used as a last resort in public-facing services because research shows that some users find selects very difficult to use.

When not to use select

The select component allows users to choose an option from a long list. Before using the select component, try asking users other questions which will allow you to present them with fewer options.

Consider using a different solution, such as radios.

How to use select

If you use the component for settings, you can make an option pre-selected by default when users first see it.

If you use the component for questions, do not pre-select any of the options in case it influences users' answers.

Select with hint

You can add hint text to help the user understand the options and choose 1 of them.

Open this with hint select example in a new tab
<div class="nhsuk-form-group">
  <label class="nhsuk-label nhsuk-label--s" for="region">
    Choose region
  </label>
  <div id="region-hint" class="nhsuk-hint">
    This can be different to what you selected before
  </div>
  <select class="nhsuk-select" id="region" name="region" aria-describedby="region-hint">
    <option value="choose" selected>Choose region</option>
    <option value="east">East of England</option>
    <option value="london">London</option>
    <option value="midlands">Midlands</option>
    <option value="yorkshire">North East and Yorkshire</option>
    <option value="northwest">North West</option>
    <option value="southeast">South East</option>
    <option value="southeast">South West</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.

Nunjucks arguments for with hint select
Name Type Required Description
id string false ID for the select box. Defaults to the value of name.
name string true The name attribute for the select.
items array true The items within the select component.
items[].value string false The value attribute 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[].divider boolean false Divider line used to separate option items.
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 The 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.
inputWrapper object false If any of formGroup.beforeInput or formGroup.afterInput have a value, a wrapping element is added around the select and inserted content. This object allows you to customise that wrapping element.
inputWrapper{}.classes string false Classes to add to the wrapping element.
inputWrapper{}.attributes object false HTML attributes (for example data attributes) to add to the wrapping element.
attributes object false HTML attributes (for example data attributes) to add to the select.
{% from "select/macro.njk" import select %}

{{ select({
  label: {
    text: "Choose region",
    size: "s"
  },
  hint: {
    text: "This can be different to what you selected before"
  },
  id: "region",
  name: "region",
  value: "choose",
  items: [
    {
      value: "choose",
      text: "Choose region"
    },
    {
      value: "east",
      text: "East of England"
    },
    {
      value: "london",
      text: "London"
    },
    {
      value: "midlands",
      text: "Midlands"
    },
    {
      value: "yorkshire",
      text: "North East and Yorkshire"
    },
    {
      value: "northwest",
      text: "North West"
    },
    {
      value: "southeast",
      text: "South East"
    },
    {
      value: "southeast",
      text: "South West"
    }
  ]
}) }}

Error messages

Display an error message if the user has not selected an option.

Style error messages as shown in the example:

Open this error select example in a new tab
<div class="nhsuk-form-group nhsuk-form-group--error">
  <label class="nhsuk-label nhsuk-label--s" for="region">
    Choose region
  </label>
  <div id="region-hint" class="nhsuk-hint">
    This can be different to what you selected before
  </div>
  <span id="region-error" class="nhsuk-error-message">
    <span class="nhsuk-u-visually-hidden">Error:</span> Choose a region
  </span>
  <select class="nhsuk-select nhsuk-select--error" id="region" name="region" aria-describedby="region-hint region-error">
    <option value="choose" selected>Choose region</option>
    <option value="east">East of England</option>
    <option value="london">London</option>
    <option value="midlands">Midlands</option>
    <option value="yorkshire">North East and Yorkshire</option>
    <option value="northwest">North West</option>
    <option value="southeast">South East</option>
    <option value="southeast">South West</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.

Nunjucks arguments for error select
Name Type Required Description
id string false ID for the select box. Defaults to the value of name.
name string true The name attribute for the select.
items array true The items within the select component.
items[].value string false The value attribute 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[].divider boolean false Divider line used to separate option items.
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 The 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.
inputWrapper object false If any of formGroup.beforeInput or formGroup.afterInput have a value, a wrapping element is added around the select and inserted content. This object allows you to customise that wrapping element.
inputWrapper{}.classes string false Classes to add to the wrapping element.
inputWrapper{}.attributes object false HTML attributes (for example data attributes) to add to the wrapping element.
attributes object false HTML attributes (for example data attributes) to add to the select.
{% from "select/macro.njk" import select %}

{{ select({
  label: {
    text: "Choose region",
    size: "s"
  },
  hint: {
    text: "This can be different to what you selected before"
  },
  errorMessage: {
    text: "Choose a region"
  },
  id: "region",
  name: "region",
  value: "choose",
  items: [
    {
      value: "choose",
      text: "Choose region"
    },
    {
      value: "east",
      text: "East of England"
    },
    {
      value: "london",
      text: "London"
    },
    {
      value: "midlands",
      text: "Midlands"
    },
    {
      value: "yorkshire",
      text: "North East and Yorkshire"
    },
    {
      value: "northwest",
      text: "North West"
    },
    {
      value: "southeast",
      text: "South East"
    },
    {
      value: "southeast",
      text: "South West"
    }
  ]
}) }}

Avoid adding functionality to allow selecting multiple options

The select component does not support selecting multiple options, as there's a history of poor usability and assistive technology support for <select multiple>. If you need to ask the user to pick more than 1 item from a list, it's almost always better to use another method, such as a list of checkboxes.

Read Select your poison (24 Accessibility).

Information: WCAG 2.2

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

Find out more in:

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 GitHub

Read more about how to feed back or share insights.

If you have any questions, get in touch with the service manual team.

Updated: November 2025