When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.
<divclass="govuk-form-group"><labelclass="govuk-label"for="sort">
Sort by
</label><selectclass="govuk-select"id="sort"name="sort"><optionvalue="published">Recently published</option><optionvalue="updated"selected>Recently updated</option><optionvalue="views">Most views</option><optionvalue="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.
Primary options
Name
Type
Description
id
string
Required.
ID for each select box.
name
string
Required.
Name property for the select.
items
array
Required.
The items within the select component.
See items.
value
string
Value for the option which should be selected. Use this as an alternative to setting the selected option on each individual item.
disabled
boolean
If true, select box will be disabled. Use the disabled option on each individual item to only disable certain options.
describedBy
string
One or more element IDs to add to the aria-describedby attribute, used to provide additional descriptive information for screenreader users.
label
object
Required.
The label used by the select component.
See label.
hint
object
Can be used to add a hint to the select component.
See hint.
errorMessage
object
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.
See errorMessage.
formGroup
object
Additional options for the form group containing the select component.
See formGroup.
classes
string
Classes to add to the select.
attributes
object
HTML attributes (for example data attributes) to add to the select.
Options for items array objects
Name
Type
Description
value
string
Value for the option. If this is omitted, the value is taken from the text content of the option element.
text
string
Required.
Text for the option item.
selected
boolean
Whether the option should be selected when the page loads. Takes precedence over the top-level value option.
disabled
boolean
Sets the option item as disabled.
attributes
object
HTML attributes (for example data attributes) to add to the option.
Options for formGroup object
Name
Type
Description
classes
string
Classes to add to the form group (for example to show error state for the whole group).
attributes
object
HTML attributes (for example data attributes) to add to the form group.
beforeInput
object
Content to add before the select used by the select component.
See formGroup beforeInput.
afterInput
object
Content to add after the select used by the select component.
See formGroup afterInput.
Options for formGroup beforeInput object
Name
Type
Description
text
string
Required.
Text to add before the select. If html is provided, the text option will be ignored.
html
string
Required.
HTML to add before the select. If html is provided, the text option will be ignored.
Options for formGroup afterInput object
Name
Type
Description
text
string
Required.
Text to add after the select. If html is provided, the text option will be ignored.
html
string
Required.
HTML to add after the select. If html is provided, the text option will be ignored.
Options for label component
Name
Type
Description
text
string
Required.
If html is set, this is not required. Text to use within the label. If html is provided, the text option will be ignored.
html
string
Required.
If text is set, this is not required. HTML to use within the label. If html is provided, the text option will be ignored.
for
string
The value of the for attribute, the ID of the input the label is associated with.
isPageHeading
boolean
Whether the label also acts as the heading for the page.
classes
string
Classes to add to the label tag.
attributes
object
HTML attributes (for example data attributes) to add to the label tag.
Options for hint component
Name
Type
Description
text
string
Required.
If html is set, this is not required. Text to use within the hint. If html is provided, the text option will be ignored.
html
string
Required.
If text is set, this is not required. HTML to use within the hint. If html is provided, the text option will be ignored.
id
string
Optional ID attribute to add to the hint span tag.
classes
string
Classes to add to the hint span tag.
attributes
object
HTML attributes (for example data attributes) to add to the hint span tag.
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 this component
The select component allows users to choose an option from a long list. Before using the select component, try asking users questions which will allow you to present them with fewer options.
Asking questions means you’re less likely to need to use the select component, and can consider using a different solution, such as radios.
How it works
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, you should not pre-select any of the options in case it influences users’ answers.
There are 2 ways to use the select component. You can use HTML or, if you’re using Nunjucks or the GOV.UK Prototype Kit, you can use the Nunjucks macro.
<divclass="govuk-form-group"><labelclass="govuk-label"for="sort">
Sort by
</label><selectclass="govuk-select"id="sort"name="sort"><optionvalue="published">Recently published</option><optionvalue="updated"selected>Recently updated</option><optionvalue="views">Most views</option><optionvalue="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.
Primary options
Name
Type
Description
id
string
Required.
ID for each select box.
name
string
Required.
Name property for the select.
items
array
Required.
The items within the select component.
See items.
value
string
Value for the option which should be selected. Use this as an alternative to setting the selected option on each individual item.
disabled
boolean
If true, select box will be disabled. Use the disabled option on each individual item to only disable certain options.
describedBy
string
One or more element IDs to add to the aria-describedby attribute, used to provide additional descriptive information for screenreader users.
label
object
Required.
The label used by the select component.
See label.
hint
object
Can be used to add a hint to the select component.
See hint.
errorMessage
object
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.
See errorMessage.
formGroup
object
Additional options for the form group containing the select component.
See formGroup.
classes
string
Classes to add to the select.
attributes
object
HTML attributes (for example data attributes) to add to the select.
Options for items array objects
Name
Type
Description
value
string
Value for the option. If this is omitted, the value is taken from the text content of the option element.
text
string
Required.
Text for the option item.
selected
boolean
Whether the option should be selected when the page loads. Takes precedence over the top-level value option.
disabled
boolean
Sets the option item as disabled.
attributes
object
HTML attributes (for example data attributes) to add to the option.
Options for formGroup object
Name
Type
Description
classes
string
Classes to add to the form group (for example to show error state for the whole group).
attributes
object
HTML attributes (for example data attributes) to add to the form group.
beforeInput
object
Content to add before the select used by the select component.
See formGroup beforeInput.
afterInput
object
Content to add after the select used by the select component.
See formGroup afterInput.
Options for formGroup beforeInput object
Name
Type
Description
text
string
Required.
Text to add before the select. If html is provided, the text option will be ignored.
html
string
Required.
HTML to add before the select. If html is provided, the text option will be ignored.
Options for formGroup afterInput object
Name
Type
Description
text
string
Required.
Text to add after the select. If html is provided, the text option will be ignored.
html
string
Required.
HTML to add after the select. If html is provided, the text option will be ignored.
Options for label component
Name
Type
Description
text
string
Required.
If html is set, this is not required. Text to use within the label. If html is provided, the text option will be ignored.
html
string
Required.
If text is set, this is not required. HTML to use within the label. If html is provided, the text option will be ignored.
for
string
The value of the for attribute, the ID of the input the label is associated with.
isPageHeading
boolean
Whether the label also acts as the heading for the page.
classes
string
Classes to add to the label tag.
attributes
object
HTML attributes (for example data attributes) to add to the label tag.
Options for hint component
Name
Type
Description
text
string
Required.
If html is set, this is not required. Text to use within the hint. If html is provided, the text option will be ignored.
html
string
Required.
If text is set, this is not required. HTML to use within the hint. If html is provided, the text option will be ignored.
id
string
Optional ID attribute to add to the hint span tag.
classes
string
Classes to add to the hint span tag.
attributes
object
HTML attributes (for example data attributes) to add to the hint span tag.
<divclass="govuk-form-group"><labelclass="govuk-label"for="location">
Choose location
</label><divid="location-hint"class="govuk-hint">
This can be different to where you went before
</div><selectclass="govuk-select"id="location"name="location"aria-describedby="location-hint"><optionvalue="choose"selected>Choose location</option><optionvalue="eastmidlands">East Midlands</option><optionvalue="eastofengland">East of England</option><optionvalue="london">London</option><optionvalue="northeast">North East</option><optionvalue="northwest">North West</option><optionvalue="southeast">South East</option><optionvalue="southwest">South West</option><optionvalue="westmidlands">West Midlands</option><optionvalue="yorkshire">Yorkshire and the Humber</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.
Primary options
Name
Type
Description
id
string
Required.
ID for each select box.
name
string
Required.
Name property for the select.
items
array
Required.
The items within the select component.
See items.
value
string
Value for the option which should be selected. Use this as an alternative to setting the selected option on each individual item.
disabled
boolean
If true, select box will be disabled. Use the disabled option on each individual item to only disable certain options.
describedBy
string
One or more element IDs to add to the aria-describedby attribute, used to provide additional descriptive information for screenreader users.
label
object
Required.
The label used by the select component.
See label.
hint
object
Can be used to add a hint to the select component.
See hint.
errorMessage
object
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.
See errorMessage.
formGroup
object
Additional options for the form group containing the select component.
See formGroup.
classes
string
Classes to add to the select.
attributes
object
HTML attributes (for example data attributes) to add to the select.
Options for items array objects
Name
Type
Description
value
string
Value for the option. If this is omitted, the value is taken from the text content of the option element.
text
string
Required.
Text for the option item.
selected
boolean
Whether the option should be selected when the page loads. Takes precedence over the top-level value option.
disabled
boolean
Sets the option item as disabled.
attributes
object
HTML attributes (for example data attributes) to add to the option.
Options for formGroup object
Name
Type
Description
classes
string
Classes to add to the form group (for example to show error state for the whole group).
attributes
object
HTML attributes (for example data attributes) to add to the form group.
beforeInput
object
Content to add before the select used by the select component.
See formGroup beforeInput.
afterInput
object
Content to add after the select used by the select component.
See formGroup afterInput.
Options for formGroup beforeInput object
Name
Type
Description
text
string
Required.
Text to add before the select. If html is provided, the text option will be ignored.
html
string
Required.
HTML to add before the select. If html is provided, the text option will be ignored.
Options for formGroup afterInput object
Name
Type
Description
text
string
Required.
Text to add after the select. If html is provided, the text option will be ignored.
html
string
Required.
HTML to add after the select. If html is provided, the text option will be ignored.
Options for label component
Name
Type
Description
text
string
Required.
If html is set, this is not required. Text to use within the label. If html is provided, the text option will be ignored.
html
string
Required.
If text is set, this is not required. HTML to use within the label. If html is provided, the text option will be ignored.
for
string
The value of the for attribute, the ID of the input the label is associated with.
isPageHeading
boolean
Whether the label also acts as the heading for the page.
classes
string
Classes to add to the label tag.
attributes
object
HTML attributes (for example data attributes) to add to the label tag.
Options for hint component
Name
Type
Description
text
string
Required.
If html is set, this is not required. Text to use within the hint. If html is provided, the text option will be ignored.
html
string
Required.
If text is set, this is not required. HTML to use within the hint. If html is provided, the text option will be ignored.
id
string
Optional ID attribute to add to the hint span tag.
classes
string
Classes to add to the hint span tag.
attributes
object
HTML attributes (for example data attributes) to add to the hint span tag.
<divclass="govuk-form-group govuk-form-group--error"><labelclass="govuk-label"for="location">
Choose location
</label><divid="location-hint"class="govuk-hint">
This can be different to where you went before
</div><pid="location-error"class="govuk-error-message"><spanclass="govuk-visually-hidden">Error:</span> Select a location
</p><selectclass="govuk-select govuk-select--error"id="location"name="location"aria-describedby="location-hint location-error"><optionvalue="choose"selected>Choose location</option><optionvalue="eastmidlands">East Midlands</option><optionvalue="eastofengland">East of England</option><optionvalue="london">London</option><optionvalue="northeast">North East</option><optionvalue="northwest">North West</option><optionvalue="southeast">South East</option><optionvalue="southwest">South West</option><optionvalue="westmidlands">West Midlands</option><optionvalue="yorkshire">Yorkshire and the Humber</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.
Primary options
Name
Type
Description
id
string
Required.
ID for each select box.
name
string
Required.
Name property for the select.
items
array
Required.
The items within the select component.
See items.
value
string
Value for the option which should be selected. Use this as an alternative to setting the selected option on each individual item.
disabled
boolean
If true, select box will be disabled. Use the disabled option on each individual item to only disable certain options.
describedBy
string
One or more element IDs to add to the aria-describedby attribute, used to provide additional descriptive information for screenreader users.
label
object
Required.
The label used by the select component.
See label.
hint
object
Can be used to add a hint to the select component.
See hint.
errorMessage
object
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.
See errorMessage.
formGroup
object
Additional options for the form group containing the select component.
See formGroup.
classes
string
Classes to add to the select.
attributes
object
HTML attributes (for example data attributes) to add to the select.
Options for items array objects
Name
Type
Description
value
string
Value for the option. If this is omitted, the value is taken from the text content of the option element.
text
string
Required.
Text for the option item.
selected
boolean
Whether the option should be selected when the page loads. Takes precedence over the top-level value option.
disabled
boolean
Sets the option item as disabled.
attributes
object
HTML attributes (for example data attributes) to add to the option.
Options for formGroup object
Name
Type
Description
classes
string
Classes to add to the form group (for example to show error state for the whole group).
attributes
object
HTML attributes (for example data attributes) to add to the form group.
beforeInput
object
Content to add before the select used by the select component.
See formGroup beforeInput.
afterInput
object
Content to add after the select used by the select component.
See formGroup afterInput.
Options for formGroup beforeInput object
Name
Type
Description
text
string
Required.
Text to add before the select. If html is provided, the text option will be ignored.
html
string
Required.
HTML to add before the select. If html is provided, the text option will be ignored.
Options for formGroup afterInput object
Name
Type
Description
text
string
Required.
Text to add after the select. If html is provided, the text option will be ignored.
html
string
Required.
HTML to add after the select. If html is provided, the text option will be ignored.
Options for label component
Name
Type
Description
text
string
Required.
If html is set, this is not required. Text to use within the label. If html is provided, the text option will be ignored.
html
string
Required.
If text is set, this is not required. HTML to use within the label. If html is provided, the text option will be ignored.
for
string
The value of the for attribute, the ID of the input the label is associated with.
isPageHeading
boolean
Whether the label also acts as the heading for the page.
classes
string
Classes to add to the label tag.
attributes
object
HTML attributes (for example data attributes) to add to the label tag.
Options for hint component
Name
Type
Description
text
string
Required.
If html is set, this is not required. Text to use within the hint. If html is provided, the text option will be ignored.
html
string
Required.
If text is set, this is not required. HTML to use within the hint. If html is provided, the text option will be ignored.
id
string
Optional ID attribute to add to the hint span tag.
classes
string
Classes to add to the hint span tag.
attributes
object
HTML attributes (for example data attributes) to add to the hint span tag.
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.
Research on this component
User research has shown that some users struggle with selects.
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