Components
Select
Help users select an item from a list.
Read the Design System guidance for select
Import
import { Select, SelectField } from 'govuk-react/select';Examples
Default
Code
<SelectField
id="sort"
name="sort"
label="Sort by"
>
{options}
</SelectField>Select with hint text
Code
<SelectField
id="sort"
name="sort"
label="Sort by"
hint="This can be different to where you went before"
>
{options}
</SelectField>Select with hint text error
Code
<SelectField
id="sort"
name="sort"
label="Sort by"
hint="This can be different to where you went before"
errorMessage="Select a location"
>
{options}
</SelectField>API reference
Select
Help users select an item from a list.
| Prop | Type |
|---|---|
error | boolean |
width | FluidWidth |
SelectField
Help users select an item from a list.
| Prop | Type |
|---|---|
labelSize | "s" | "m" | "l" | "xl" |
labelIsPageHeading | boolean |
width | FluidWidth |
labelThe label used by the select component. | ReactNode |
hintCan be used to add a hint to the select component. | ReactNode |
errorMessageCan 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 | ReactNode |