Form elements
–
Radios
Use radios when you want users to select only 1 option from a list.
Radios updates
Added smaller radios in version 10.1
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. Deprecated options are marked as "Deprecated".
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 | Description |
|---|---|---|
| id | string | The ID of the radios component. |
| fieldset | object | The fieldset used by the radios component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the radios component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the radios component. The error message component will not display if you use a falsy value for errorMessage, for example false or null.
See macro options for error |
|
form |
object |
Additional options for the form group containing the radios component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each radio input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for the radio items.
|
| items | array | Required. The radio items within the radios component. See macro options for items. |
| value | string |
The value for the radio which should be checked when the page loads. Use this as an alternative to setting the checked option on each individual item.
|
| small | boolean |
If set to true, small radios will be used.
|
| inline | boolean |
If set to true, inline radios will be used.
|
| classes | string | Classes to add to the radios container. |
| attributes | object | HTML attributes (for example data attributes) to add to the radios container. |
| 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. |
|
before |
object |
Content to add before all radio items within the radios component.
See macro options for form |
|
after |
object |
Content to add after all radio items within the radios component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within each radio item 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 each radio item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the radio item. If omitted, then idPrefix string will be applied.
|
| value | string |
Required.
The value attribute for the radio input.
|
| label | object | Subset of options for the label used by each radio item within the radios component. See macro options for items label. |
| hint | object | Can be used to add a hint to each radio item within the radios component. See macro options for hint. |
| divider | string |
Divider text to separate radio items, for example the text "or".
|
| checked | boolean |
Whether the radio should be checked when the page loads. Takes precedence over the top-level value option.
|
| conditional | object | Provide additional content to reveal when the radio is checked. See macro options for items conditional. |
| disabled | boolean |
If true, radio will be disabled.
|
| classes | string | Classes to add to the radio input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the radio input tag. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the label tag. |
| classes | string | Classes to add to the label tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the label tag. |
| Name | Type | Description |
|---|---|---|
| html | string | Required. The HTML to reveal when the radio is checked. |
When to use radios
Use radios if users can only choose 1 option from a list.
When not to use radios
Do not use radios if users might need to select more than 1 option. Use checkboxes instead.
How to use radios
Position radios to the left of their labels. This makes them easier to find, especially for users of screen magnifiers.
Unlike with checkboxes, users can only select 1 option from a list of radios. Do not assume that users will know how many options they can select based on the visual difference between radios and checkboxes alone. If needed, add a hint explaining this, for example, "Select 1 option".
Do not pre-select radio options as this makes it more likely that users will:
- not realise they've missed a question
- submit the wrong answer
Users cannot go back to having no option selected once they have selected an option, without refreshing their browser window. So you should include "None of these" or "I do not know" if they are valid options. In any case, it's best to beware binary choices.
Order radio options alphabetically by default. In some cases, it's helpful to order them from most-to-least common options, for example, by population size. But be careful, as this can reinforce bias. If in doubt, order alphabetically.
Group radios together in a <fieldset> with a <legend> that describes them. You can see an example at the top of this page. This is usually a question, like "Are you 18 or over?". Read more about using fieldset.
Inline radios
If there are only 2 short options, you can either stack the radios vertically or display them horizontally (inline).
On small screens such as mobile devices, the radios will still stack vertically.
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. Deprecated options are marked as "Deprecated".
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 | Description |
|---|---|---|
| id | string | The ID of the radios component. |
| fieldset | object | The fieldset used by the radios component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the radios component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the radios component. The error message component will not display if you use a falsy value for errorMessage, for example false or null.
See macro options for error |
|
form |
object |
Additional options for the form group containing the radios component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each radio input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for the radio items.
|
| items | array | Required. The radio items within the radios component. See macro options for items. |
| value | string |
The value for the radio which should be checked when the page loads. Use this as an alternative to setting the checked option on each individual item.
|
| small | boolean |
If set to true, small radios will be used.
|
| inline | boolean |
If set to true, inline radios will be used.
|
| classes | string | Classes to add to the radios container. |
| attributes | object | HTML attributes (for example data attributes) to add to the radios container. |
| 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. |
|
before |
object |
Content to add before all radio items within the radios component.
See macro options for form |
|
after |
object |
Content to add after all radio items within the radios component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within each radio item 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 each radio item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the radio item. If omitted, then idPrefix string will be applied.
|
| value | string |
Required.
The value attribute for the radio input.
|
| label | object | Subset of options for the label used by each radio item within the radios component. See macro options for items label. |
| hint | object | Can be used to add a hint to each radio item within the radios component. See macro options for hint. |
| divider | string |
Divider text to separate radio items, for example the text "or".
|
| checked | boolean |
Whether the radio should be checked when the page loads. Takes precedence over the top-level value option.
|
| conditional | object | Provide additional content to reveal when the radio is checked. See macro options for items conditional. |
| disabled | boolean |
If true, radio will be disabled.
|
| classes | string | Classes to add to the radio input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the radio input tag. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the label tag. |
| classes | string | Classes to add to the label tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the label tag. |
| Name | Type | Description |
|---|---|---|
| html | string | Required. The HTML to reveal when the radio is checked. |
Radios with hints
Use hint text to give users help in context. Read more about hint text.
Do not assume that users will know that they can only select 1 option based on the visual difference between radios and checkboxes. If needed, add a hint explaining this, for example, "Select 1 option".
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. Deprecated options are marked as "Deprecated".
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 | Description |
|---|---|---|
| id | string | The ID of the radios component. |
| fieldset | object | The fieldset used by the radios component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the radios component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the radios component. The error message component will not display if you use a falsy value for errorMessage, for example false or null.
See macro options for error |
|
form |
object |
Additional options for the form group containing the radios component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each radio input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for the radio items.
|
| items | array | Required. The radio items within the radios component. See macro options for items. |
| value | string |
The value for the radio which should be checked when the page loads. Use this as an alternative to setting the checked option on each individual item.
|
| small | boolean |
If set to true, small radios will be used.
|
| inline | boolean |
If set to true, inline radios will be used.
|
| classes | string | Classes to add to the radios container. |
| attributes | object | HTML attributes (for example data attributes) to add to the radios container. |
| 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. |
|
before |
object |
Content to add before all radio items within the radios component.
See macro options for form |
|
after |
object |
Content to add after all radio items within the radios component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within each radio item 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 each radio item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the radio item. If omitted, then idPrefix string will be applied.
|
| value | string |
Required.
The value attribute for the radio input.
|
| label | object | Subset of options for the label used by each radio item within the radios component. See macro options for items label. |
| hint | object | Can be used to add a hint to each radio item within the radios component. See macro options for hint. |
| divider | string |
Divider text to separate radio items, for example the text "or".
|
| checked | boolean |
Whether the radio should be checked when the page loads. Takes precedence over the top-level value option.
|
| conditional | object | Provide additional content to reveal when the radio is checked. See macro options for items conditional. |
| disabled | boolean |
If true, radio will be disabled.
|
| classes | string | Classes to add to the radio input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the radio input tag. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the label tag. |
| classes | string | Classes to add to the label tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the label tag. |
| Name | Type | Description |
|---|---|---|
| html | string | Required. The HTML to reveal when the radio is checked. |
Radio items with hints
You can add hints to radios to give more information about the options.
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. Deprecated options are marked as "Deprecated".
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 | Description |
|---|---|---|
| id | string | The ID of the radios component. |
| fieldset | object | The fieldset used by the radios component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the radios component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the radios component. The error message component will not display if you use a falsy value for errorMessage, for example false or null.
See macro options for error |
|
form |
object |
Additional options for the form group containing the radios component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each radio input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for the radio items.
|
| items | array | Required. The radio items within the radios component. See macro options for items. |
| value | string |
The value for the radio which should be checked when the page loads. Use this as an alternative to setting the checked option on each individual item.
|
| small | boolean |
If set to true, small radios will be used.
|
| inline | boolean |
If set to true, inline radios will be used.
|
| classes | string | Classes to add to the radios container. |
| attributes | object | HTML attributes (for example data attributes) to add to the radios container. |
| 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. |
|
before |
object |
Content to add before all radio items within the radios component.
See macro options for form |
|
after |
object |
Content to add after all radio items within the radios component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within each radio item 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 each radio item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the radio item. If omitted, then idPrefix string will be applied.
|
| value | string |
Required.
The value attribute for the radio input.
|
| label | object | Subset of options for the label used by each radio item within the radios component. See macro options for items label. |
| hint | object | Can be used to add a hint to each radio item within the radios component. See macro options for hint. |
| divider | string |
Divider text to separate radio items, for example the text "or".
|
| checked | boolean |
Whether the radio should be checked when the page loads. Takes precedence over the top-level value option.
|
| conditional | object | Provide additional content to reveal when the radio is checked. See macro options for items conditional. |
| disabled | boolean |
If true, radio will be disabled.
|
| classes | string | Classes to add to the radio input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the radio input tag. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the label tag. |
| classes | string | Classes to add to the label tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the label tag. |
| Name | Type | Description |
|---|---|---|
| html | string | Required. The HTML to reveal when the radio is checked. |
Radio items with a text divider
If 1 or more of your radio options is different from the others, it can help users if you separate them using a text divider. The text is usually the word "or".
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. Deprecated options are marked as "Deprecated".
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 | Description |
|---|---|---|
| id | string | The ID of the radios component. |
| fieldset | object | The fieldset used by the radios component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the radios component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the radios component. The error message component will not display if you use a falsy value for errorMessage, for example false or null.
See macro options for error |
|
form |
object |
Additional options for the form group containing the radios component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each radio input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for the radio items.
|
| items | array | Required. The radio items within the radios component. See macro options for items. |
| value | string |
The value for the radio which should be checked when the page loads. Use this as an alternative to setting the checked option on each individual item.
|
| small | boolean |
If set to true, small radios will be used.
|
| inline | boolean |
If set to true, inline radios will be used.
|
| classes | string | Classes to add to the radios container. |
| attributes | object | HTML attributes (for example data attributes) to add to the radios container. |
| 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. |
|
before |
object |
Content to add before all radio items within the radios component.
See macro options for form |
|
after |
object |
Content to add after all radio items within the radios component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within each radio item 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 each radio item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the radio item. If omitted, then idPrefix string will be applied.
|
| value | string |
Required.
The value attribute for the radio input.
|
| label | object | Subset of options for the label used by each radio item within the radios component. See macro options for items label. |
| hint | object | Can be used to add a hint to each radio item within the radios component. See macro options for hint. |
| divider | string |
Divider text to separate radio items, for example the text "or".
|
| checked | boolean |
Whether the radio should be checked when the page loads. Takes precedence over the top-level value option.
|
| conditional | object | Provide additional content to reveal when the radio is checked. See macro options for items conditional. |
| disabled | boolean |
If true, radio will be disabled.
|
| classes | string | Classes to add to the radio input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the radio input tag. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the label tag. |
| classes | string | Classes to add to the label tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the label tag. |
| Name | Type | Description |
|---|---|---|
| html | string | Required. The HTML to reveal when the radio is checked. |
Conditionally revealing a related question
You can add a conditionally revealing question to radios, so users only see the question when it’s relevant to them.
For example, you could reveal an email address input only when a user chooses to be contacted by email.
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. Deprecated options are marked as "Deprecated".
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 | Description |
|---|---|---|
| id | string | The ID of the radios component. |
| fieldset | object | The fieldset used by the radios component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the radios component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the radios component. The error message component will not display if you use a falsy value for errorMessage, for example false or null.
See macro options for error |
|
form |
object |
Additional options for the form group containing the radios component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each radio input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for the radio items.
|
| items | array | Required. The radio items within the radios component. See macro options for items. |
| value | string |
The value for the radio which should be checked when the page loads. Use this as an alternative to setting the checked option on each individual item.
|
| small | boolean |
If set to true, small radios will be used.
|
| inline | boolean |
If set to true, inline radios will be used.
|
| classes | string | Classes to add to the radios container. |
| attributes | object | HTML attributes (for example data attributes) to add to the radios container. |
| 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. |
|
before |
object |
Content to add before all radio items within the radios component.
See macro options for form |
|
after |
object |
Content to add after all radio items within the radios component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within each radio item 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 each radio item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the radio item. If omitted, then idPrefix string will be applied.
|
| value | string |
Required.
The value attribute for the radio input.
|
| label | object | Subset of options for the label used by each radio item within the radios component. See macro options for items label. |
| hint | object | Can be used to add a hint to each radio item within the radios component. See macro options for hint. |
| divider | string |
Divider text to separate radio items, for example the text "or".
|
| checked | boolean |
Whether the radio should be checked when the page loads. Takes precedence over the top-level value option.
|
| conditional | object | Provide additional content to reveal when the radio is checked. See macro options for items conditional. |
| disabled | boolean |
If true, radio will be disabled.
|
| classes | string | Classes to add to the radio input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the radio input tag. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the label tag. |
| classes | string | Classes to add to the label tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the label tag. |
| Name | Type | Description |
|---|---|---|
| html | string | Required. The HTML to reveal when the radio is checked. |
Keep it simple. If you need to add a lot of content, consider showing it on the next page in the process instead.
Do not use this component to add conditionally revealing questions to inline radios.
Only conditionally reveal questions. Do not show or hide anything that is not a question.
Known issues
Users are not always notified when a conditionally revealed question is shown or hidden. This fails WCAG 2.2 success criterion 4.1.2 name, role, value (W3C)
However, GOV.UK found that screen reader users did not have difficulty answering a conditionally revealed question as long as it's simple. It confused users when they conditionally revealed complicated questions, particularly questions with more than 1 part.
Smaller radios
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. Deprecated options are marked as "Deprecated".
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 | Description |
|---|---|---|
| id | string | The ID of the radios component. |
| fieldset | object | The fieldset used by the radios component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the radios component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the radios component. The error message component will not display if you use a falsy value for errorMessage, for example false or null.
See macro options for error |
|
form |
object |
Additional options for the form group containing the radios component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each radio input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for the radio items.
|
| items | array | Required. The radio items within the radios component. See macro options for items. |
| value | string |
The value for the radio which should be checked when the page loads. Use this as an alternative to setting the checked option on each individual item.
|
| small | boolean |
If set to true, small radios will be used.
|
| inline | boolean |
If set to true, inline radios will be used.
|
| classes | string | Classes to add to the radios container. |
| attributes | object | HTML attributes (for example data attributes) to add to the radios container. |
| 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. |
|
before |
object |
Content to add before all radio items within the radios component.
See macro options for form |
|
after |
object |
Content to add after all radio items within the radios component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within each radio item 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 each radio item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the radio item. If omitted, then idPrefix string will be applied.
|
| value | string |
Required.
The value attribute for the radio input.
|
| label | object | Subset of options for the label used by each radio item within the radios component. See macro options for items label. |
| hint | object | Can be used to add a hint to each radio item within the radios component. See macro options for hint. |
| divider | string |
Divider text to separate radio items, for example the text "or".
|
| checked | boolean |
Whether the radio should be checked when the page loads. Takes precedence over the top-level value option.
|
| conditional | object | Provide additional content to reveal when the radio is checked. See macro options for items conditional. |
| disabled | boolean |
If true, radio will be disabled.
|
| classes | string | Classes to add to the radio input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the radio input tag. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the label tag. |
| classes | string | Classes to add to the label tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the label tag. |
| Name | Type | Description |
|---|---|---|
| html | string | Required. The HTML to reveal when the radio is checked. |
Use standard-sized radios in most cases.
You can use small radios where you need something less visually prominent. For example, on:
- a page of search results where users need to see and change search filters without distracting them from the results
- on information-dense screens in services designed for repeat use, like staff-facing systems
Error messages
Display an error message if the user has not:
- selected any radios
- answered a conditionally revealed question
Style error messages like this.
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. Deprecated options are marked as "Deprecated".
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 | Description |
|---|---|---|
| id | string | The ID of the radios component. |
| fieldset | object | The fieldset used by the radios component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the radios component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the radios component. The error message component will not display if you use a falsy value for errorMessage, for example false or null.
See macro options for error |
|
form |
object |
Additional options for the form group containing the radios component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each radio input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for the radio items.
|
| items | array | Required. The radio items within the radios component. See macro options for items. |
| value | string |
The value for the radio which should be checked when the page loads. Use this as an alternative to setting the checked option on each individual item.
|
| small | boolean |
If set to true, small radios will be used.
|
| inline | boolean |
If set to true, inline radios will be used.
|
| classes | string | Classes to add to the radios container. |
| attributes | object | HTML attributes (for example data attributes) to add to the radios container. |
| 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. |
|
before |
object |
Content to add before all radio items within the radios component.
See macro options for form |
|
after |
object |
Content to add after all radio items within the radios component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all radio items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all radio items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within each radio item 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 each radio item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the radio item. If omitted, then idPrefix string will be applied.
|
| value | string |
Required.
The value attribute for the radio input.
|
| label | object | Subset of options for the label used by each radio item within the radios component. See macro options for items label. |
| hint | object | Can be used to add a hint to each radio item within the radios component. See macro options for hint. |
| divider | string |
Divider text to separate radio items, for example the text "or".
|
| checked | boolean |
Whether the radio should be checked when the page loads. Takes precedence over the top-level value option.
|
| conditional | object | Provide additional content to reveal when the radio is checked. See macro options for items conditional. |
| disabled | boolean |
If true, radio will be disabled.
|
| classes | string | Classes to add to the radio input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the radio input tag. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the label tag. |
| classes | string | Classes to add to the label tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the label tag. |
| Name | Type | Description |
|---|---|---|
| html | string | Required. The HTML to reveal when the radio is checked. |
Follow:
Research
Our checkboxes are based on the GOV.UK design system. Read a GOV.UK blog post about their updates to radios and checkboxes.
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: November 2025