--- url: "https://design-system.service.gov.uk/components/checkboxes/" titulek: "Checkboxes – GOV.UK Design System" h1: "Checkboxes" popis: "Let users select one or more options by using the checkboxes component" jazyk: "en" kanonicka: "https://design-system.service.gov.uk/components/checkboxes/" drobecky: ["Home", "Components"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 01:21:29" znaku: 74652 slov: 10902 kodovani: "utf-8" sha256: "8af5dc5c45c4e76635fc55a4dcce4635111c4969150058bdea34cac63bcfbfef" --- # Checkboxes Let users select one or more options by using the checkboxes component. - HTML - Nunjucks HTML ```

Which types of waste do you transport?

Select all that apply
``` Nunjucks 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](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options 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. object Can be used to add a fieldset to the checkboxes component. [See macro options for fieldset](/components/fieldset/#options-fieldset-example). object Can be used to add a hint to the checkboxes component. See macro options for hint. 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 errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the checkboxes component. See macro options for formGroup. 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. string **Required.** Name attribute for all checkbox items. array **Required.** The checkbox items within the checkboxes component. See macro options for items. 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. string Classes to add to the checkboxes container. object HTML attributes (for example data attributes) to add to the checkboxes container. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before all checkbox items within the checkboxes component. See macro options for formGroup beforeInputs. object Content to add after all checkbox items within the checkboxes component. See macro options for formGroup afterInputs. Options for formGroup `beforeInputs` object string **Required.** Text to add before all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before all checkbox items. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInputs` object string **Required.** Text to add after all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after all checkbox items. If `html` is provided, the `text` option will be ignored. Options for `items` array objects 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. 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. string Specific ID attribute for the checkbox item. If omitted, then component global `idPrefix` option will be applied. string Specific name for the checkbox item. If omitted, then component global `name` string will be applied. string **Required.** Value for the checkbox input. object Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. object Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. string Divider text to separate checkbox items, for example the text `"or"`. boolean Whether the checkbox should be checked when the page loads. Takes precedence over the top-level `values` option. object Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. string If set to `"exclusive"`, implements a ‘None of these’ type behaviour via JavaScript when checkboxes are clicked. boolean If `true`, checkbox will be disabled. object HTML attributes (for example data attributes) to add to the checkbox input tag. Options for items `label` component string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for items `conditional` object string **Required.** The HTML to reveal when the checkbox is checked. Options for `hint` component 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. 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. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {{ govukCheckboxes({ name: "waste", fieldset: { legend: { text: "Which types of waste do you transport?", isPageHeading: true, classes: "govuk-fieldset__legend--l" } }, hint: { text: "Select all that apply" }, items: [ { value: "carcasses", text: "Waste from animal carcasses" }, { value: "mines", text: "Waste from mines or quarries" }, { value: "farm", text: "Farm or agricultural waste" } ] }) }} ``` ## When to use this component Use the checkboxes component when you need to help users: - select multiple options from a list - toggle a single option on or off ## When not to use this component Do not use the checkboxes component if users can only choose one option from a selection. In this case, use the [Radios component](/components/radios/). ## How it works Always position checkboxes to the left of their labels. This makes them easier to find, especially for users of screen magnifiers. Unlike with radios, users can select multiple options from a list of checkboxes. 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 all that apply’. 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 can be helpful to order them from most-to-least common options. For example, you could order options for ‘What is your nationality?’ based on population size. Group checkboxes together in a `
` with a `` that describes them, as shown in the examples on this page. This is usually a question, like ‘How would you like to be contacted?’. ### If you’re asking one question on the page If you’re asking just [one question per page](/patterns/question-pages/#start-by-asking-one-question-per-page) as recommended, you can set the contents of the `` as the page heading. This is good practice as it means that users of screen readers will only hear the contents once. Read more about [why and how to set legends as headings](/get-started/labels-legends-headings/). There are 2 ways to use the checkboxes component. You can use HTML or, if you’re using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro. - HTML - Nunjucks HTML ```

Which types of waste do you transport?

Select all that apply
``` Nunjucks 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](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options 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. object Can be used to add a fieldset to the checkboxes component. [See macro options for fieldset](/components/fieldset/#options-fieldset-example). object Can be used to add a hint to the checkboxes component. See macro options for hint. 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 errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the checkboxes component. See macro options for formGroup. 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. string **Required.** Name attribute for all checkbox items. array **Required.** The checkbox items within the checkboxes component. See macro options for items. 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. string Classes to add to the checkboxes container. object HTML attributes (for example data attributes) to add to the checkboxes container. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before all checkbox items within the checkboxes component. See macro options for formGroup beforeInputs. object Content to add after all checkbox items within the checkboxes component. See macro options for formGroup afterInputs. Options for formGroup `beforeInputs` object string **Required.** Text to add before all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before all checkbox items. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInputs` object string **Required.** Text to add after all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after all checkbox items. If `html` is provided, the `text` option will be ignored. Options for `items` array objects 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. 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. string Specific ID attribute for the checkbox item. If omitted, then component global `idPrefix` option will be applied. string Specific name for the checkbox item. If omitted, then component global `name` string will be applied. string **Required.** Value for the checkbox input. object Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. object Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. string Divider text to separate checkbox items, for example the text `"or"`. boolean Whether the checkbox should be checked when the page loads. Takes precedence over the top-level `values` option. object Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. string If set to `"exclusive"`, implements a ‘None of these’ type behaviour via JavaScript when checkboxes are clicked. boolean If `true`, checkbox will be disabled. object HTML attributes (for example data attributes) to add to the checkbox input tag. Options for items `label` component string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for items `conditional` object string **Required.** The HTML to reveal when the checkbox is checked. Options for `hint` component 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. 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. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {{ govukCheckboxes({ name: "waste", fieldset: { legend: { text: "Which types of waste do you transport?", isPageHeading: true, classes: "govuk-fieldset__legend--l" } }, hint: { text: "Select all that apply" }, items: [ { value: "carcasses", text: "Waste from animal carcasses" }, { value: "mines", text: "Waste from mines or quarries" }, { value: "farm", text: "Farm or agricultural waste" } ] }) }} ``` ### If you’re asking more than one question on the page If you’re asking more than one question on the page, do not set the contents of the `` as the page heading. Read more about [asking multiple questions on Question pages](/patterns/question-pages/#asking-multiple-questions-on-a-page). - HTML - Nunjucks HTML ```
Which types of waste do you transport?
Select all that apply
``` Nunjucks 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](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options 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. object Can be used to add a fieldset to the checkboxes component. [See macro options for fieldset](/components/fieldset/#options-fieldset-example). object Can be used to add a hint to the checkboxes component. See macro options for hint. 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 errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the checkboxes component. See macro options for formGroup. 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. string **Required.** Name attribute for all checkbox items. array **Required.** The checkbox items within the checkboxes component. See macro options for items. 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. string Classes to add to the checkboxes container. object HTML attributes (for example data attributes) to add to the checkboxes container. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before all checkbox items within the checkboxes component. See macro options for formGroup beforeInputs. object Content to add after all checkbox items within the checkboxes component. See macro options for formGroup afterInputs. Options for formGroup `beforeInputs` object string **Required.** Text to add before all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before all checkbox items. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInputs` object string **Required.** Text to add after all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after all checkbox items. If `html` is provided, the `text` option will be ignored. Options for `items` array objects 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. 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. string Specific ID attribute for the checkbox item. If omitted, then component global `idPrefix` option will be applied. string Specific name for the checkbox item. If omitted, then component global `name` string will be applied. string **Required.** Value for the checkbox input. object Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. object Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. string Divider text to separate checkbox items, for example the text `"or"`. boolean Whether the checkbox should be checked when the page loads. Takes precedence over the top-level `values` option. object Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. string If set to `"exclusive"`, implements a ‘None of these’ type behaviour via JavaScript when checkboxes are clicked. boolean If `true`, checkbox will be disabled. object HTML attributes (for example data attributes) to add to the checkbox input tag. Options for items `label` component string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for items `conditional` object string **Required.** The HTML to reveal when the checkbox is checked. Options for `hint` component 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. 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. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {{ govukCheckboxes({ name: "waste", fieldset: { legend: { text: "Which types of waste do you transport?" } }, hint: { text: "Select all that apply" }, items: [ { value: "carcasses", text: "Waste from animal carcasses" }, { value: "mines", text: "Waste from mines or quarries" }, { value: "farm", text: "Farm or agricultural waste" } ] }) }} ``` ### Checkbox items with hints You can add hints to checkbox items to provide additional information about the options. Keep each hint to a single short sentence, without any full stops. Screen readers will read out the entire text when users interact with an item. This could frustrate users if the text is long. Do not use links in hint text. While screen readers will read out the link text when describing the item, they usually do not tell users the text is a link. - HTML - Nunjucks HTML ```

What is your nationality?

If you have dual nationality, select all options that are relevant to you.
including English, Scottish, Welsh and Northern Irish
``` Nunjucks 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](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options 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. object Can be used to add a fieldset to the checkboxes component. [See macro options for fieldset](/components/fieldset/#options-fieldset-example). object Can be used to add a hint to the checkboxes component. See macro options for hint. 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 errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the checkboxes component. See macro options for formGroup. 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. string **Required.** Name attribute for all checkbox items. array **Required.** The checkbox items within the checkboxes component. See macro options for items. 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. string Classes to add to the checkboxes container. object HTML attributes (for example data attributes) to add to the checkboxes container. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before all checkbox items within the checkboxes component. See macro options for formGroup beforeInputs. object Content to add after all checkbox items within the checkboxes component. See macro options for formGroup afterInputs. Options for formGroup `beforeInputs` object string **Required.** Text to add before all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before all checkbox items. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInputs` object string **Required.** Text to add after all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after all checkbox items. If `html` is provided, the `text` option will be ignored. Options for `items` array objects 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. 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. string Specific ID attribute for the checkbox item. If omitted, then component global `idPrefix` option will be applied. string Specific name for the checkbox item. If omitted, then component global `name` string will be applied. string **Required.** Value for the checkbox input. object Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. object Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. string Divider text to separate checkbox items, for example the text `"or"`. boolean Whether the checkbox should be checked when the page loads. Takes precedence over the top-level `values` option. object Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. string If set to `"exclusive"`, implements a ‘None of these’ type behaviour via JavaScript when checkboxes are clicked. boolean If `true`, checkbox will be disabled. object HTML attributes (for example data attributes) to add to the checkbox input tag. Options for items `label` component string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for items `conditional` object string **Required.** The HTML to reveal when the checkbox is checked. Options for `hint` component 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. 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. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {{ govukCheckboxes({ name: "nationality", fieldset: { legend: { text: "What is your nationality?", isPageHeading: true, classes: "govuk-fieldset__legend--l" } }, hint: { text: "If you have dual nationality, select all options that are relevant to you." }, items: [ { value: "british", text: "British", hint: { text: "including English, Scottish, Welsh and Northern Irish" } }, { value: "irish", text: "Irish" }, { value: "other", text: "Citizen of another country" } ] }) }} ``` ### Add an option for ‘none’ When ‘none’ would be a valid answer, give users the option to check a box to say none of the other options apply to them – without this option, users would have to leave all of the boxes unchecked. Giving users this option also makes sure they do not skip the question by accident. Remember to [start by asking one question per page in your service](/patterns/question-pages/#start-by-asking-one-question-per-page). You might be able to remove the need for a ‘none’ option by asking the user a better question or filtering them out with a ‘filter question’ beforehand. The GOV.UK Service Manual has guidance on [designing good questions](https://www.gov.uk/service-manual/design/designing-good-questions). Show the ‘none’ option last. Separate it from the other options using a divider. The text is usually the word ‘or’. Write a label that repeats the key part of the question. For example, for the question ‘Will you be travelling to any of these countries?’, say ‘No, I will not be travelling to any of these countries.’ To enable some JavaScript that unchecks all other checkboxes when the user clicks ‘None’, add the `exclusive` behaviour to the ‘none’ checkbox. - HTML - Nunjucks HTML ```

Will you be travelling to any of these countries?

Select all countries that apply
or
``` Nunjucks 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](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options 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. object Can be used to add a fieldset to the checkboxes component. [See macro options for fieldset](/components/fieldset/#options-fieldset-example). object Can be used to add a hint to the checkboxes component. See macro options for hint. 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 errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the checkboxes component. See macro options for formGroup. 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. string **Required.** Name attribute for all checkbox items. array **Required.** The checkbox items within the checkboxes component. See macro options for items. 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. string Classes to add to the checkboxes container. object HTML attributes (for example data attributes) to add to the checkboxes container. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before all checkbox items within the checkboxes component. See macro options for formGroup beforeInputs. object Content to add after all checkbox items within the checkboxes component. See macro options for formGroup afterInputs. Options for formGroup `beforeInputs` object string **Required.** Text to add before all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before all checkbox items. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInputs` object string **Required.** Text to add after all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after all checkbox items. If `html` is provided, the `text` option will be ignored. Options for `items` array objects 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. 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. string Specific ID attribute for the checkbox item. If omitted, then component global `idPrefix` option will be applied. string Specific name for the checkbox item. If omitted, then component global `name` string will be applied. string **Required.** Value for the checkbox input. object Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. object Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. string Divider text to separate checkbox items, for example the text `"or"`. boolean Whether the checkbox should be checked when the page loads. Takes precedence over the top-level `values` option. object Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. string If set to `"exclusive"`, implements a ‘None of these’ type behaviour via JavaScript when checkboxes are clicked. boolean If `true`, checkbox will be disabled. object HTML attributes (for example data attributes) to add to the checkbox input tag. Options for items `label` component string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for items `conditional` object string **Required.** The HTML to reveal when the checkbox is checked. Options for `hint` component 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. 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. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {{ govukCheckboxes({ name: "countries", fieldset: { legend: { text: "Will you be travelling to any of these countries?", isPageHeading: true, classes: "govuk-fieldset__legend--l" } }, hint: { text: "Select all countries that apply" }, items: [ { value: "france", text: "France" }, { value: "portugal", text: "Portugal" }, { value: "spain", text: "Spain" }, { divider: "or" }, { value: "none", text: "No, I will not be travelling to any of these countries", behaviour: "exclusive" } ] }) }} ``` If JavaScript is unavailable, and a user selects both the ‘none’ checkbox and another checkbox, display an error message. - HTML - Nunjucks HTML ```

Will you be travelling to any of these countries?

Error: Select countries you will be travelling to, or select ‘No, I will not be travelling to any of these countries’

or
``` Nunjucks 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](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options 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. object Can be used to add a fieldset to the checkboxes component. [See macro options for fieldset](/components/fieldset/#options-fieldset-example). object Can be used to add a hint to the checkboxes component. See macro options for hint. 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 errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the checkboxes component. See macro options for formGroup. 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. string **Required.** Name attribute for all checkbox items. array **Required.** The checkbox items within the checkboxes component. See macro options for items. 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. string Classes to add to the checkboxes container. object HTML attributes (for example data attributes) to add to the checkboxes container. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before all checkbox items within the checkboxes component. See macro options for formGroup beforeInputs. object Content to add after all checkbox items within the checkboxes component. See macro options for formGroup afterInputs. Options for formGroup `beforeInputs` object string **Required.** Text to add before all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before all checkbox items. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInputs` object string **Required.** Text to add after all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after all checkbox items. If `html` is provided, the `text` option will be ignored. Options for `items` array objects 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. 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. string Specific ID attribute for the checkbox item. If omitted, then component global `idPrefix` option will be applied. string Specific name for the checkbox item. If omitted, then component global `name` string will be applied. string **Required.** Value for the checkbox input. object Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. object Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. string Divider text to separate checkbox items, for example the text `"or"`. boolean Whether the checkbox should be checked when the page loads. Takes precedence over the top-level `values` option. object Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. string If set to `"exclusive"`, implements a ‘None of these’ type behaviour via JavaScript when checkboxes are clicked. boolean If `true`, checkbox will be disabled. object HTML attributes (for example data attributes) to add to the checkbox input tag. Options for items `label` component string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for items `conditional` object string **Required.** The HTML to reveal when the checkbox is checked. Options for `hint` component 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. 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. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {{ govukCheckboxes({ name: "countries", fieldset: { legend: { text: "Will you be travelling to any of these countries?", isPageHeading: true, classes: "govuk-fieldset__legend--l" } }, errorMessage: { text: "Select countries you will be travelling to, or select ‘No, I will not be travelling to any of these countries’" }, items: [ { value: "france", text: "France", checked: true }, { value: "portugal", text: "Portugal" }, { value: "spain", text: "Spain" }, { divider: "or" }, { value: "none", text: "No, I will not be travelling to any of these countries", checked: true, behaviour: "exclusive" } ] }) }} ``` You can ask the user a related question when they select a particular checkbox, so they only see the question when it’s relevant to them. This might make 2 related questions easier to answer by grouping them on the same page. For example, you could reveal a phone number input when the user selects the ‘Contact me by phone’ option. - HTML - Nunjucks HTML ```

How would you like to be contacted?

Select all options that are relevant to you
``` Nunjucks 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](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options 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. object Can be used to add a fieldset to the checkboxes component. [See macro options for fieldset](/components/fieldset/#options-fieldset-example). object Can be used to add a hint to the checkboxes component. See macro options for hint. 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 errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the checkboxes component. See macro options for formGroup. 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. string **Required.** Name attribute for all checkbox items. array **Required.** The checkbox items within the checkboxes component. See macro options for items. 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. string Classes to add to the checkboxes container. object HTML attributes (for example data attributes) to add to the checkboxes container. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before all checkbox items within the checkboxes component. See macro options for formGroup beforeInputs. object Content to add after all checkbox items within the checkboxes component. See macro options for formGroup afterInputs. Options for formGroup `beforeInputs` object string **Required.** Text to add before all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before all checkbox items. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInputs` object string **Required.** Text to add after all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after all checkbox items. If `html` is provided, the `text` option will be ignored. Options for `items` array objects 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. 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. string Specific ID attribute for the checkbox item. If omitted, then component global `idPrefix` option will be applied. string Specific name for the checkbox item. If omitted, then component global `name` string will be applied. string **Required.** Value for the checkbox input. object Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. object Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. string Divider text to separate checkbox items, for example the text `"or"`. boolean Whether the checkbox should be checked when the page loads. Takes precedence over the top-level `values` option. object Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. string If set to `"exclusive"`, implements a ‘None of these’ type behaviour via JavaScript when checkboxes are clicked. boolean If `true`, checkbox will be disabled. object HTML attributes (for example data attributes) to add to the checkbox input tag. Options for items `label` component string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for items `conditional` object string **Required.** The HTML to reveal when the checkbox is checked. Options for `hint` component 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. 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. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {% from "govuk/components/input/macro.njk" import govukInput %} {% set emailHtml %} {{ govukInput({ id: "contact-by-email", name: "contactByEmail", type: "email", autocomplete: "email", spellcheck: false, classes: "govuk-!-width-one-third", label: { text: "Email address" } }) }} {% endset -%} {% set phoneHtml %} {{ govukInput({ id: "contact-by-phone", name: "contactByPhone", type: "tel", autocomplete: "tel", classes: "govuk-!-width-one-third", label: { text: "Phone number" } }) }} {% endset -%} {% set textHtml %} {{ govukInput({ id: "contact-by-text", name: "contactByText", type: "tel", autocomplete: "tel", classes: "govuk-!-width-one-third", label: { text: "Mobile phone number" } }) }} {% endset -%} {{ govukCheckboxes({ name: "contact", fieldset: { legend: { text: "How would you like to be contacted?", isPageHeading: true, classes: "govuk-fieldset__legend--l" } }, hint: { text: "Select all options that are relevant to you" }, items: [ { value: "email", text: "Email", conditional: { html: emailHtml } }, { value: "phone", text: "Phone", conditional: { html: phoneHtml } }, { value: "text message", text: "Text message", conditional: { html: textHtml } } ] }) }} ``` Keep it simple. If the related question is complicated or has more than one part, show it on the next page in the process instead. You should 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](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value.html). However, we found that screen reader users did not have difficulty answering a conditionally revealed question - as long as it’s kept simple. It confused our test users when we conditionally revealed complicated questions to them. We’ll keep looking for opportunities to [learn more about how conditionally revealed questions should be used in services](https://github.com/alphagov/govuk-design-system-backlog/issues/37). ### Smaller checkboxes Use standard-sized checkboxes in most cases. However, smaller checkboxes work well on pages where it’s helpful to make them less visually prominent. For example, on a page of search results, the main user need is to see the results. Using smaller checkboxes lets users see and change search filters without distracting them from the main content. - HTML - Nunjucks HTML ```

Organisation

``` Nunjucks 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](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options 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. object Can be used to add a fieldset to the checkboxes component. [See macro options for fieldset](/components/fieldset/#options-fieldset-example). object Can be used to add a hint to the checkboxes component. See macro options for hint. 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 errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the checkboxes component. See macro options for formGroup. 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. string **Required.** Name attribute for all checkbox items. array **Required.** The checkbox items within the checkboxes component. See macro options for items. 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. string Classes to add to the checkboxes container. object HTML attributes (for example data attributes) to add to the checkboxes container. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before all checkbox items within the checkboxes component. See macro options for formGroup beforeInputs. object Content to add after all checkbox items within the checkboxes component. See macro options for formGroup afterInputs. Options for formGroup `beforeInputs` object string **Required.** Text to add before all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before all checkbox items. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInputs` object string **Required.** Text to add after all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after all checkbox items. If `html` is provided, the `text` option will be ignored. Options for `items` array objects 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. 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. string Specific ID attribute for the checkbox item. If omitted, then component global `idPrefix` option will be applied. string Specific name for the checkbox item. If omitted, then component global `name` string will be applied. string **Required.** Value for the checkbox input. object Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. object Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. string Divider text to separate checkbox items, for example the text `"or"`. boolean Whether the checkbox should be checked when the page loads. Takes precedence over the top-level `values` option. object Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. string If set to `"exclusive"`, implements a ‘None of these’ type behaviour via JavaScript when checkboxes are clicked. boolean If `true`, checkbox will be disabled. object HTML attributes (for example data attributes) to add to the checkbox input tag. Options for items `label` component string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for items `conditional` object string **Required.** The HTML to reveal when the checkbox is checked. Options for `hint` component 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. 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. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {{ govukCheckboxes({ name: "organisation", classes: "govuk-checkboxes--small", fieldset: { legend: { text: "Organisation", isPageHeading: true, classes: "govuk-fieldset__legend--m" } }, items: [ { value: "hmrc", text: "HM Revenue and Customs (HMRC)" }, { value: "employment-tribunal", text: "Employment Tribunal" }, { value: "MOD", text: "Ministry of Defence" }, { value: "DfT", text: "Department for Transport" } ] }) }} ``` Small checkboxes can work well on information dense screens in services designed for repeat use, like caseworking systems. In services like these, the risk that they will not be noticed is lower because users return to the screen multiple times. ### Error messages Error messages should be styled like this: - HTML - Nunjucks HTML ```

What is your nationality?

If you have dual nationality, select all options that are relevant to you

Error: Select if you are British, Irish or a citizen of a different country

including English, Scottish, Welsh and Northern Irish
``` Nunjucks 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](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options 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. object Can be used to add a fieldset to the checkboxes component. [See macro options for fieldset](/components/fieldset/#options-fieldset-example). object Can be used to add a hint to the checkboxes component. See macro options for hint. 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 errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the checkboxes component. See macro options for formGroup. 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. string **Required.** Name attribute for all checkbox items. array **Required.** The checkbox items within the checkboxes component. See macro options for items. 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. string Classes to add to the checkboxes container. object HTML attributes (for example data attributes) to add to the checkboxes container. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before all checkbox items within the checkboxes component. See macro options for formGroup beforeInputs. object Content to add after all checkbox items within the checkboxes component. See macro options for formGroup afterInputs. Options for formGroup `beforeInputs` object string **Required.** Text to add before all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before all checkbox items. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInputs` object string **Required.** Text to add after all checkbox items. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after all checkbox items. If `html` is provided, the `text` option will be ignored. Options for `items` array objects 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. 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. string Specific ID attribute for the checkbox item. If omitted, then component global `idPrefix` option will be applied. string Specific name for the checkbox item. If omitted, then component global `name` string will be applied. string **Required.** Value for the checkbox input. object Subset of options for the label used by each checkbox item within the checkboxes component. See macro options for items label. object Can be used to add a hint to each checkbox item within the checkboxes component. See macro options for hint. string Divider text to separate checkbox items, for example the text `"or"`. boolean Whether the checkbox should be checked when the page loads. Takes precedence over the top-level `values` option. object Provide additional content to reveal when the checkbox is checked. See macro options for items conditional. string If set to `"exclusive"`, implements a ‘None of these’ type behaviour via JavaScript when checkboxes are clicked. boolean If `true`, checkbox will be disabled. object HTML attributes (for example data attributes) to add to the checkbox input tag. Options for items `label` component string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for items `conditional` object string **Required.** The HTML to reveal when the checkbox is checked. Options for `hint` component 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. 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. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {{ govukCheckboxes({ name: "nationality", fieldset: { legend: { text: "What is your nationality?", isPageHeading: true, classes: "govuk-fieldset__legend--l" } }, hint: { text: "If you have dual nationality, select all options that are relevant to you" }, errorMessage: { text: "Select if you are British, Irish or a citizen of a different country" }, items: [ { value: "british", text: "British", hint: { text: "including English, Scottish, Welsh and Northern Irish" } }, { value: "irish", text: "Irish" }, { value: "other", text: "Citizen of another country" } ] }) }} ``` Make sure errors follow the guidance in the [Error message component](/components/error-message/) and have specific error messages for specific error states. #### If nothing is selected and the question has options in it Say ‘Select if [whatever it is]’. For example, ‘Select if you are British, Irish or a citizen of a different country’. #### If nothing is selected and the question does not have options in it Say ‘Select [whatever it is]’. For example, ‘Select your nationality or nationalities’. #### If users check both a ‘none’ checkbox and another checkbox Say: Select [option label text] or select ‘[none of the above label text]’ For example: Select countries you will be travelling to, or select ‘No, I will not be travelling to any of these countries’ ## Research on this component If you’ve done any user research involving conditionally revealed questions, particularly with users of assistive technologies, [tell us what you’ve learned by adding a comment to the discussion about this component](https://github.com/alphagov/govuk-design-system-backlog/issues/37). Read a blog post about [an update to the radios and checkboxes components in 2016](https://designnotes.blog.gov.uk/2016/11/30/weve-updated-the-radios-and-checkboxes-on-gov-uk/). ## Help improve this component To help make sure that this page is useful, relevant and up to date, you can: - take part in the [‘Checkboxes’ discussion on GitHub](https://github.com/alphagov/govuk-design-system-backlog/issues/37) and share your research - [propose a change on GitHub](https://github.com/alphagov/govuk-design-system/edit/main/src/components/checkboxes/index.md) – read more about [how to propose changes in GitHub](/community/propose-a-content-change-using-github/) ## Need help? If you’ve got a question about the GOV.UK Design System, [contact the team](/contact/).