Form elements
–
Checkboxes
Use checkboxes to let users select 1 or more options on a form.
Checkboxes updated in August 2025
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 checkboxes component. |
|
described |
string |
One or more element IDs to add to the input aria-describedby attribute without a fieldset, used to provide additional descriptive information for screenreader users.
|
| fieldset | object | Can be used to add a fieldset to the checkboxes component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the checkboxes component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the checkboxes 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 checkboxes component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each checkbox item input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for all checkbox items.
|
| items | array | Required. The checkbox items within the checkboxes component. See macro options for items. |
| values | array |
Array of values for checkboxes 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 checkboxes will be used.
|
| classes | string | Classes to add to the checkboxes container. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkboxes 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 checkbox items within the checkboxes component.
See macro options for form |
|
after |
object |
Content to add after all checkbox items within the checkboxes component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all checkbox items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all checkbox 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 checkbox 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 checkbox item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the checkbox item. If omitted, then component global idPrefix option will be applied.
|
| name | string |
Specific name attribute for the checkbox item. If omitted, then component global name string will be applied.
|
| value | string |
Required.
The value attribute for the checkbox input.
|
| label | object | Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. |
| hint | object | Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. |
| divider | string |
Divider text to separate checkbox items, for example the text "or".
|
| checked | boolean |
Whether the checkbox should be checked when the page loads. Takes precedence over the top-level values option.
|
| conditional | object | Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. |
| disabled | boolean |
If true, checkbox will be disabled.
|
| classes | string | Classes to add to the checkbox input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkbox input tag. |
| exclusive | boolean |
If set to true, marks this checkbox as the None option in a None of these type behaviour. Unchecking all other checkboxes in the group when None is clicked.
|
|
exclusive |
string |
Used in conjunction with exclusive - this should be set to a string which groups checkboxes together into a set for use in a None of these scenario.
|
| 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 checkbox is checked. |
When to use checkboxes
Use checkboxes when you need to help users:
- select more than 1 option from a list
- toggle a single option on or off
When not to use checkboxes
Do not use the checkboxes component if users can only choose 1 option from a selection. In this case, use a radio.
How to use checkboxes
Position checkboxes to the left of their labels. This makes them easier to find, especially for users of screen magnifiers.
Do not pre-select checkbox options as this makes it more likely that users will:
- not realise they've missed a question
- submit the wrong answer
Order checkbox 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 checkboxes together in a <fieldset> with a <legend> that describes them. You can see an example at the top of this page. The legend is usually a question, like "How do you want to be contacted about this?".
Read more about using fieldset.
Checkboxes with hint text
Unlike with radios, users can select more than 1 option from a list of checkboxes. Do not assume that users will know how many options they can select.
Use hint text to give users help in context. For example, say "Select all the options that are relevant to you". Read more about hint text.
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 checkboxes component. |
|
described |
string |
One or more element IDs to add to the input aria-describedby attribute without a fieldset, used to provide additional descriptive information for screenreader users.
|
| fieldset | object | Can be used to add a fieldset to the checkboxes component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the checkboxes component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the checkboxes 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 checkboxes component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each checkbox item input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for all checkbox items.
|
| items | array | Required. The checkbox items within the checkboxes component. See macro options for items. |
| values | array |
Array of values for checkboxes 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 checkboxes will be used.
|
| classes | string | Classes to add to the checkboxes container. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkboxes 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 checkbox items within the checkboxes component.
See macro options for form |
|
after |
object |
Content to add after all checkbox items within the checkboxes component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all checkbox items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all checkbox 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 checkbox 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 checkbox item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the checkbox item. If omitted, then component global idPrefix option will be applied.
|
| name | string |
Specific name attribute for the checkbox item. If omitted, then component global name string will be applied.
|
| value | string |
Required.
The value attribute for the checkbox input.
|
| label | object | Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. |
| hint | object | Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. |
| divider | string |
Divider text to separate checkbox items, for example the text "or".
|
| checked | boolean |
Whether the checkbox should be checked when the page loads. Takes precedence over the top-level values option.
|
| conditional | object | Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. |
| disabled | boolean |
If true, checkbox will be disabled.
|
| classes | string | Classes to add to the checkbox input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkbox input tag. |
| exclusive | boolean |
If set to true, marks this checkbox as the None option in a None of these type behaviour. Unchecking all other checkboxes in the group when None is clicked.
|
|
exclusive |
string |
Used in conjunction with exclusive - this should be set to a string which groups checkboxes together into a set for use in a None of these scenario.
|
| 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 checkbox is checked. |
Checkbox items with hints
You can add hints to checkbox items to provide additional 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 checkboxes component. |
|
described |
string |
One or more element IDs to add to the input aria-describedby attribute without a fieldset, used to provide additional descriptive information for screenreader users.
|
| fieldset | object | Can be used to add a fieldset to the checkboxes component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the checkboxes component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the checkboxes 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 checkboxes component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each checkbox item input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for all checkbox items.
|
| items | array | Required. The checkbox items within the checkboxes component. See macro options for items. |
| values | array |
Array of values for checkboxes 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 checkboxes will be used.
|
| classes | string | Classes to add to the checkboxes container. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkboxes 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 checkbox items within the checkboxes component.
See macro options for form |
|
after |
object |
Content to add after all checkbox items within the checkboxes component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all checkbox items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all checkbox 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 checkbox 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 checkbox item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the checkbox item. If omitted, then component global idPrefix option will be applied.
|
| name | string |
Specific name attribute for the checkbox item. If omitted, then component global name string will be applied.
|
| value | string |
Required.
The value attribute for the checkbox input.
|
| label | object | Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. |
| hint | object | Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. |
| divider | string |
Divider text to separate checkbox items, for example the text "or".
|
| checked | boolean |
Whether the checkbox should be checked when the page loads. Takes precedence over the top-level values option.
|
| conditional | object | Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. |
| disabled | boolean |
If true, checkbox will be disabled.
|
| classes | string | Classes to add to the checkbox input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkbox input tag. |
| exclusive | boolean |
If set to true, marks this checkbox as the None option in a None of these type behaviour. Unchecking all other checkboxes in the group when None is clicked.
|
|
exclusive |
string |
Used in conjunction with exclusive - this should be set to a string which groups checkboxes together into a set for use in a None of these scenario.
|
| 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 checkbox is checked. |
Add an option for "none"
You can give users the option to say none of the other options apply to them.
This option means users need to actively select "none" rather than leave all the boxes unchecked, which makes sure they do not skip the question by accident.
Remember to start by asking 1 question per page. You might be able to remove the need for a "none" option by asking the user a better question or by using filter questions to filter users out beforehand.
Show the "none" option last. Separate it from the other options using a divider, normally the word "or".
Write a label that repeats the key part of the question. For example, for the question "Do you have any of these symptoms?", say "No, I do not have any of these symptoms". Avoid phrases like "none of the above" because this is a visual reference and might be hard for people who use screen readers to understand.
To enable some JavaScript that unchecks all other checkboxes when the user clicks "none", add the data-checkbox-exclusive behaviour to the "none" checkbox.
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 checkboxes component. |
|
described |
string |
One or more element IDs to add to the input aria-describedby attribute without a fieldset, used to provide additional descriptive information for screenreader users.
|
| fieldset | object | Can be used to add a fieldset to the checkboxes component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the checkboxes component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the checkboxes 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 checkboxes component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each checkbox item input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for all checkbox items.
|
| items | array | Required. The checkbox items within the checkboxes component. See macro options for items. |
| values | array |
Array of values for checkboxes 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 checkboxes will be used.
|
| classes | string | Classes to add to the checkboxes container. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkboxes 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 checkbox items within the checkboxes component.
See macro options for form |
|
after |
object |
Content to add after all checkbox items within the checkboxes component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all checkbox items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all checkbox 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 checkbox 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 checkbox item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the checkbox item. If omitted, then component global idPrefix option will be applied.
|
| name | string |
Specific name attribute for the checkbox item. If omitted, then component global name string will be applied.
|
| value | string |
Required.
The value attribute for the checkbox input.
|
| label | object | Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. |
| hint | object | Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. |
| divider | string |
Divider text to separate checkbox items, for example the text "or".
|
| checked | boolean |
Whether the checkbox should be checked when the page loads. Takes precedence over the top-level values option.
|
| conditional | object | Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. |
| disabled | boolean |
If true, checkbox will be disabled.
|
| classes | string | Classes to add to the checkbox input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkbox input tag. |
| exclusive | boolean |
If set to true, marks this checkbox as the None option in a None of these type behaviour. Unchecking all other checkboxes in the group when None is clicked.
|
|
exclusive |
string |
Used in conjunction with exclusive - this should be set to a string which groups checkboxes together into a set for use in a None of these scenario.
|
| 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 checkbox is checked. |
If JavaScript is unavailable, and a user selects both the "none" checkbox and another checkbox, display an error message.
Conditionally revealing a related question
You can add a conditionally revealing related question to checkboxes, so users only see the question when it's relevant to them.
For example, you could reveal a phone number input only when a user chooses to be contacted by phone.
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 checkboxes component. |
|
described |
string |
One or more element IDs to add to the input aria-describedby attribute without a fieldset, used to provide additional descriptive information for screenreader users.
|
| fieldset | object | Can be used to add a fieldset to the checkboxes component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the checkboxes component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the checkboxes 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 checkboxes component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each checkbox item input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for all checkbox items.
|
| items | array | Required. The checkbox items within the checkboxes component. See macro options for items. |
| values | array |
Array of values for checkboxes 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 checkboxes will be used.
|
| classes | string | Classes to add to the checkboxes container. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkboxes 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 checkbox items within the checkboxes component.
See macro options for form |
|
after |
object |
Content to add after all checkbox items within the checkboxes component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all checkbox items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all checkbox 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 checkbox 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 checkbox item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the checkbox item. If omitted, then component global idPrefix option will be applied.
|
| name | string |
Specific name attribute for the checkbox item. If omitted, then component global name string will be applied.
|
| value | string |
Required.
The value attribute for the checkbox input.
|
| label | object | Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. |
| hint | object | Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. |
| divider | string |
Divider text to separate checkbox items, for example the text "or".
|
| checked | boolean |
Whether the checkbox should be checked when the page loads. Takes precedence over the top-level values option.
|
| conditional | object | Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. |
| disabled | boolean |
If true, checkbox will be disabled.
|
| classes | string | Classes to add to the checkbox input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkbox input tag. |
| exclusive | boolean |
If set to true, marks this checkbox as the None option in a None of these type behaviour. Unchecking all other checkboxes in the group when None is clicked.
|
|
exclusive |
string |
Used in conjunction with exclusive - this should be set to a string which groups checkboxes together into a set for use in a None of these scenario.
|
| 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 checkbox 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.
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.
Smaller checkboxes
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 checkboxes component. |
|
described |
string |
One or more element IDs to add to the input aria-describedby attribute without a fieldset, used to provide additional descriptive information for screenreader users.
|
| fieldset | object | Can be used to add a fieldset to the checkboxes component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the checkboxes component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the checkboxes 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 checkboxes component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each checkbox item input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for all checkbox items.
|
| items | array | Required. The checkbox items within the checkboxes component. See macro options for items. |
| values | array |
Array of values for checkboxes 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 checkboxes will be used.
|
| classes | string | Classes to add to the checkboxes container. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkboxes 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 checkbox items within the checkboxes component.
See macro options for form |
|
after |
object |
Content to add after all checkbox items within the checkboxes component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all checkbox items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all checkbox 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 checkbox 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 checkbox item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the checkbox item. If omitted, then component global idPrefix option will be applied.
|
| name | string |
Specific name attribute for the checkbox item. If omitted, then component global name string will be applied.
|
| value | string |
Required.
The value attribute for the checkbox input.
|
| label | object | Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. |
| hint | object | Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. |
| divider | string |
Divider text to separate checkbox items, for example the text "or".
|
| checked | boolean |
Whether the checkbox should be checked when the page loads. Takes precedence over the top-level values option.
|
| conditional | object | Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. |
| disabled | boolean |
If true, checkbox will be disabled.
|
| classes | string | Classes to add to the checkbox input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkbox input tag. |
| exclusive | boolean |
If set to true, marks this checkbox as the None option in a None of these type behaviour. Unchecking all other checkboxes in the group when None is clicked.
|
|
exclusive |
string |
Used in conjunction with exclusive - this should be set to a string which groups checkboxes together into a set for use in a None of these scenario.
|
| 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 checkbox is checked. |
Use standard-sized checkboxes in most cases.
You can use small checkboxes 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
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 checkboxes component. |
|
described |
string |
One or more element IDs to add to the input aria-describedby attribute without a fieldset, used to provide additional descriptive information for screenreader users.
|
| fieldset | object | Can be used to add a fieldset to the checkboxes component. See macro options for fieldset. |
| hint | object | Can be used to add a hint to the checkboxes component. See macro options for hint. |
|
error |
object |
Can be used to add an error message to the checkboxes 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 checkboxes component.
See macro options for form |
|
id |
string |
Optional prefix. This is used to prefix the id attribute for each checkbox item input, hint and error message, separated by -. Defaults to the name option value.
|
| name | string |
Required.
The name attribute for all checkbox items.
|
| items | array | Required. The checkbox items within the checkboxes component. See macro options for items. |
| values | array |
Array of values for checkboxes 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 checkboxes will be used.
|
| classes | string | Classes to add to the checkboxes container. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkboxes 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 checkbox items within the checkboxes component.
See macro options for form |
|
after |
object |
Content to add after all checkbox items within the checkboxes component.
See macro options for form |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add before all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add before all checkbox items. If html is provided, the text option will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
Text to add after all checkbox items. If html is provided, the text option will be ignored.
|
| html | string |
Required.
HTML to add after all checkbox 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 checkbox 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 checkbox item label. If html is provided, the text option will be ignored.
|
| id | string |
Specific id attribute for the checkbox item. If omitted, then component global idPrefix option will be applied.
|
| name | string |
Specific name attribute for the checkbox item. If omitted, then component global name string will be applied.
|
| value | string |
Required.
The value attribute for the checkbox input.
|
| label | object | Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. |
| hint | object | Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. |
| divider | string |
Divider text to separate checkbox items, for example the text "or".
|
| checked | boolean |
Whether the checkbox should be checked when the page loads. Takes precedence over the top-level values option.
|
| conditional | object | Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. |
| disabled | boolean |
If true, checkbox will be disabled.
|
| classes | string | Classes to add to the checkbox input tag. |
| attributes | object | HTML attributes (for example data attributes) to add to the checkbox input tag. |
| exclusive | boolean |
If set to true, marks this checkbox as the None option in a None of these type behaviour. Unchecking all other checkboxes in the group when None is clicked.
|
|
exclusive |
string |
Used in conjunction with exclusive - this should be set to a string which groups checkboxes together into a set for use in a None of these scenario.
|
| 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 checkbox 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