Components

Checkboxes

Let users select one or more options by using the checkboxes component.

<div class="govuk-form-group">
  <fieldset class="govuk-fieldset" aria-describedby="waste-hint">
    <legend class="govuk-fieldset__legend govuk-fieldset__legend--xl">
      <h1 class="govuk-fieldset__heading">
        Which types of waste do you transport?
      </h1>
    </legend>
    <span id="waste-hint" class="govuk-hint">
      Select all that apply.
    </span>
    <div class="govuk-checkboxes">
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="waste-1" name="waste" type="checkbox" value="carcasses">
        <label class="govuk-label govuk-checkboxes__label" for="waste-1">
          Waste from animal carcasses
        </label>
      </div>
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="waste-2" name="waste" type="checkbox" value="mines">
        <label class="govuk-label govuk-checkboxes__label" for="waste-2">
          Waste from mines or quarries
        </label>
      </div>
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="waste-3" name="waste" type="checkbox" value="farm">
        <label class="govuk-label govuk-checkboxes__label" for="waste-3">
          Farm or agricultural waste
        </label>
      </div>
    </div>
  </fieldset>
</div>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
fieldset object Options for the fieldset component (e.g. legend). See fieldset.
hint object Options for the hint component (e.g. text). See hint.
errorMessage object Options for the errorMessage component (e.g. text). See errorMessage.
formGroup object Options for the form-group wrapper See formGroup.
idPrefix string String to prefix id for each checkbox item if no id is specified on each item. If not passed, fall back to using the name option instead.
name string Required. Name attribute for all checkbox items.
items array Required. Array of checkbox items objects. See items.
classes string Classes to add to the checkboxes container.
attributes object HTML attributes (for example data attributes) to add to the anchor tag.
Options for formGroup
Name Type Description
classes string Optional classes to add to the form group (e.g. to show error state for the whole group)
Options for items
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 argument 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 argument will be ignored.
id string Specific id attribute for the checkbox item. If omitted, then idPrefix option will be applied.
name string Required. Specific name for the checkbox item. If omitted, then component global name string will be applied.
value string Required. Value for the checkbox input.
label object Provide attributes and classes to each checkbox item label. See label.
hint object Provide hint to each checkbox item. See hint.
checked boolean If true, checkbox will be checked.
conditional boolean If true, content provided will be revealed when the item is checked.
conditional.html string Provide content for the conditional reveal.
disabled boolean If true, checkbox will be disabled.
attributes object HTML attributes (for example data attributes) to add to the checkbox input tag.
Options for hint
Name Type Description
text string Required. If `html` is set, this is not required. Text to use within the hint. If `html` is provided, the `text` argument will be ignored.
html string Required. If `text` is set, this is not required. HTML to use within the hint. If `html` is provided, the `text` argument will be ignored.
id string Required. Optional id attribute to add to the hint span tag.
classes string Classes to add to the hint span tag.
attributes object HTML attributes (for example data attributes) to add to the hint span tag.
Options for label
Name Type Description
text string Required. If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` argument will be ignored.
html string Required. If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` argument will be ignored.
for string Required. The value of the for attribute, the id of the input the label is associated with.
isPageHeading boolean Whether the label also acts as the heading for the page.
classes string Classes to add to the label tag.
attributes object HTML attributes (for example data attributes) to add to the label tag.
{% from "checkboxes/macro.njk" import govukCheckboxes %}

{{ govukCheckboxes({
  idPrefix: "waste",
  name: "waste",
  fieldset: {
    legend: {
      text: "Which types of waste do you transport?",
      isPageHeading: true,
      classes: "govuk-fieldset__legend--xl"
    }
  },
  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.

How it works

Checkboxes are grouped together in a <fieldset> with a <legend> 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 are asking just one question per page as recommended, you can set the contents of the <legend> 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.

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’.

There are 2 ways to use the checkboxes component. You can use HTML or, if you’re using Nunjucks or the GOV.UK Prototype Kit, you can use the Nunjucks macro.

<div class="govuk-form-group">
  <fieldset class="govuk-fieldset" aria-describedby="waste-hint">
    <legend class="govuk-fieldset__legend govuk-fieldset__legend--xl">
      <h1 class="govuk-fieldset__heading">
        Which types of waste do you transport?
      </h1>
    </legend>
    <span id="waste-hint" class="govuk-hint">
      Select all that apply.
    </span>
    <div class="govuk-checkboxes">
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="waste-1" name="waste" type="checkbox" value="carcasses">
        <label class="govuk-label govuk-checkboxes__label" for="waste-1">
          Waste from animal carcasses
        </label>
      </div>
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="waste-2" name="waste" type="checkbox" value="mines">
        <label class="govuk-label govuk-checkboxes__label" for="waste-2">
          Waste from mines or quarries
        </label>
      </div>
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="waste-3" name="waste" type="checkbox" value="farm">
        <label class="govuk-label govuk-checkboxes__label" for="waste-3">
          Farm or agricultural waste
        </label>
      </div>
    </div>
  </fieldset>
</div>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
fieldset object Options for the fieldset component (e.g. legend). See fieldset.
hint object Options for the hint component (e.g. text). See hint.
errorMessage object Options for the errorMessage component (e.g. text). See errorMessage.
formGroup object Options for the form-group wrapper See formGroup.
idPrefix string String to prefix id for each checkbox item if no id is specified on each item. If not passed, fall back to using the name option instead.
name string Required. Name attribute for all checkbox items.
items array Required. Array of checkbox items objects. See items.
classes string Classes to add to the checkboxes container.
attributes object HTML attributes (for example data attributes) to add to the anchor tag.
Options for formGroup
Name Type Description
classes string Optional classes to add to the form group (e.g. to show error state for the whole group)
Options for items
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 argument 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 argument will be ignored.
id string Specific id attribute for the checkbox item. If omitted, then idPrefix option will be applied.
name string Required. Specific name for the checkbox item. If omitted, then component global name string will be applied.
value string Required. Value for the checkbox input.
label object Provide attributes and classes to each checkbox item label. See label.
hint object Provide hint to each checkbox item. See hint.
checked boolean If true, checkbox will be checked.
conditional boolean If true, content provided will be revealed when the item is checked.
conditional.html string Provide content for the conditional reveal.
disabled boolean If true, checkbox will be disabled.
attributes object HTML attributes (for example data attributes) to add to the checkbox input tag.
Options for hint
Name Type Description
text string Required. If `html` is set, this is not required. Text to use within the hint. If `html` is provided, the `text` argument will be ignored.
html string Required. If `text` is set, this is not required. HTML to use within the hint. If `html` is provided, the `text` argument will be ignored.
id string Required. Optional id attribute to add to the hint span tag.
classes string Classes to add to the hint span tag.
attributes object HTML attributes (for example data attributes) to add to the hint span tag.
Options for label
Name Type Description
text string Required. If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` argument will be ignored.
html string Required. If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` argument will be ignored.
for string Required. The value of the for attribute, the id of the input the label is associated with.
isPageHeading boolean Whether the label also acts as the heading for the page.
classes string Classes to add to the label tag.
attributes object HTML attributes (for example data attributes) to add to the label tag.
{% from "checkboxes/macro.njk" import govukCheckboxes %}

{{ govukCheckboxes({
  idPrefix: "waste",
  name: "waste",
  fieldset: {
    legend: {
      text: "Which types of waste do you transport?",
      isPageHeading: true,
      classes: "govuk-fieldset__legend--xl"
    }
  },
  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.

<div class="govuk-form-group">
  <fieldset class="govuk-fieldset" aria-describedby="nationality-hint">
    <legend class="govuk-fieldset__legend govuk-fieldset__legend--xl">
      <h1 class="govuk-fieldset__heading">
        What is your nationality?
      </h1>
    </legend>
    <span id="nationality-hint" class="govuk-hint">
      If you have dual nationality, select all options that are relevant to you.
    </span>
    <div class="govuk-checkboxes">
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="nationality-1" name="nationality" type="checkbox" value="british" aria-describedby="nationality-1-item-hint">
        <label class="govuk-label govuk-checkboxes__label" for="nationality-1">
          British
        </label>
        <span id="nationality-1-item-hint" class="govuk-hint govuk-checkboxes__hint">
          including English, Scottish, Welsh and Northern Irish
        </span>
      </div>
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="nationality-2" name="nationality" type="checkbox" value="irish">
        <label class="govuk-label govuk-checkboxes__label" for="nationality-2">
          Irish
        </label>
      </div>
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="nationality-3" name="nationality" type="checkbox" value="other">
        <label class="govuk-label govuk-checkboxes__label" for="nationality-3">
          Citizen of another country
        </label>
      </div>
    </div>
  </fieldset>
</div>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
fieldset object Options for the fieldset component (e.g. legend). See fieldset.
hint object Options for the hint component (e.g. text). See hint.
errorMessage object Options for the errorMessage component (e.g. text). See errorMessage.
formGroup object Options for the form-group wrapper See formGroup.
idPrefix string String to prefix id for each checkbox item if no id is specified on each item. If not passed, fall back to using the name option instead.
name string Required. Name attribute for all checkbox items.
items array Required. Array of checkbox items objects. See items.
classes string Classes to add to the checkboxes container.
attributes object HTML attributes (for example data attributes) to add to the anchor tag.
Options for formGroup
Name Type Description
classes string Optional classes to add to the form group (e.g. to show error state for the whole group)
Options for items
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 argument 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 argument will be ignored.
id string Specific id attribute for the checkbox item. If omitted, then idPrefix option will be applied.
name string Required. Specific name for the checkbox item. If omitted, then component global name string will be applied.
value string Required. Value for the checkbox input.
label object Provide attributes and classes to each checkbox item label. See label.
hint object Provide hint to each checkbox item. See hint.
checked boolean If true, checkbox will be checked.
conditional boolean If true, content provided will be revealed when the item is checked.
conditional.html string Provide content for the conditional reveal.
disabled boolean If true, checkbox will be disabled.
attributes object HTML attributes (for example data attributes) to add to the checkbox input tag.
Options for hint
Name Type Description
text string Required. If `html` is set, this is not required. Text to use within the hint. If `html` is provided, the `text` argument will be ignored.
html string Required. If `text` is set, this is not required. HTML to use within the hint. If `html` is provided, the `text` argument will be ignored.
id string Required. Optional id attribute to add to the hint span tag.
classes string Classes to add to the hint span tag.
attributes object HTML attributes (for example data attributes) to add to the hint span tag.
Options for label
Name Type Description
text string Required. If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` argument will be ignored.
html string Required. If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` argument will be ignored.
for string Required. The value of the for attribute, the id of the input the label is associated with.
isPageHeading boolean Whether the label also acts as the heading for the page.
classes string Classes to add to the label tag.
attributes object HTML attributes (for example data attributes) to add to the label tag.
{% from "checkboxes/macro.njk" import govukCheckboxes %}

{{ govukCheckboxes({
  idPrefix: "nationality",
  name: "nationality",
  fieldset: {
    legend: {
      text: "What is your nationality?",
      isPageHeading: true,
      classes: "govuk-fieldset__legend--xl"
    }
  },
  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"
    }
  ]
}) }}

Conditionally revealing content

You can add conditionally revealing content to checkboxes, so users only see content 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.

<div class="govuk-form-group">
  <fieldset class="govuk-fieldset" aria-describedby="citizenship-conditional-hint">
    <legend class="govuk-fieldset__legend govuk-fieldset__legend--xl">
      <h1 class="govuk-fieldset__heading">
        How would you like to be contacted?
      </h1>
    </legend>
    <span id="citizenship-conditional-hint" class="govuk-hint">
      Select all options that are relevant to you.
    </span>
    <div class="govuk-checkboxes" data-module="checkboxes">
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="citizenship-conditional-1" name="citizen" type="checkbox" value="email" data-aria-controls="conditional-citizenship-conditional-1">
        <label class="govuk-label govuk-checkboxes__label" for="citizenship-conditional-1">
          Email
        </label>
      </div>
      <div class="govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden" id="conditional-citizenship-conditional-1">
        <div class="govuk-form-group">
          <label class="govuk-label" for="contact-by-email">
            Email address
          </label>
          <input class="govuk-input govuk-!-width-one-third" id="contact-by-email" name="contact-by-email" type="email">
        </div>

      </div>
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="citizenship-conditional-2" name="citizen" type="checkbox" value="phone" data-aria-controls="conditional-citizenship-conditional-2">
        <label class="govuk-label govuk-checkboxes__label" for="citizenship-conditional-2">
          Phone
        </label>
      </div>
      <div class="govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden" id="conditional-citizenship-conditional-2">
        <div class="govuk-form-group">
          <label class="govuk-label" for="contact-by-phone">
            Phone number
          </label>
          <input class="govuk-input govuk-!-width-one-third" id="contact-by-phone" name="contact-by-phone" type="tel">
        </div>

      </div>
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="citizenship-conditional-3" name="citizen" type="checkbox" value="text message" data-aria-controls="conditional-citizenship-conditional-3">
        <label class="govuk-label govuk-checkboxes__label" for="citizenship-conditional-3">
          Text message
        </label>
      </div>
      <div class="govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden" id="conditional-citizenship-conditional-3">
        <div class="govuk-form-group">
          <label class="govuk-label" for="contact-by-text">
            Mobile phone number
          </label>
          <input class="govuk-input govuk-!-width-one-third" id="contact-by-text" name="contact-by-text" type="tel">
        </div>

      </div>
    </div>
  </fieldset>
</div>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
fieldset object Options for the fieldset component (e.g. legend). See fieldset.
hint object Options for the hint component (e.g. text). See hint.
errorMessage object Options for the errorMessage component (e.g. text). See errorMessage.
formGroup object Options for the form-group wrapper See formGroup.
idPrefix string String to prefix id for each checkbox item if no id is specified on each item. If not passed, fall back to using the name option instead.
name string Required. Name attribute for all checkbox items.
items array Required. Array of checkbox items objects. See items.
classes string Classes to add to the checkboxes container.
attributes object HTML attributes (for example data attributes) to add to the anchor tag.
Options for formGroup
Name Type Description
classes string Optional classes to add to the form group (e.g. to show error state for the whole group)
Options for items
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 argument 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 argument will be ignored.
id string Specific id attribute for the checkbox item. If omitted, then idPrefix option will be applied.
name string Required. Specific name for the checkbox item. If omitted, then component global name string will be applied.
value string Required. Value for the checkbox input.
label object Provide attributes and classes to each checkbox item label. See label.
hint object Provide hint to each checkbox item. See hint.
checked boolean If true, checkbox will be checked.
conditional boolean If true, content provided will be revealed when the item is checked.
conditional.html string Provide content for the conditional reveal.
disabled boolean If true, checkbox will be disabled.
attributes object HTML attributes (for example data attributes) to add to the checkbox input tag.
Options for hint
Name Type Description
text string Required. If `html` is set, this is not required. Text to use within the hint. If `html` is provided, the `text` argument will be ignored.
html string Required. If `text` is set, this is not required. HTML to use within the hint. If `html` is provided, the `text` argument will be ignored.
id string Required. Optional id attribute to add to the hint span tag.
classes string Classes to add to the hint span tag.
attributes object HTML attributes (for example data attributes) to add to the hint span tag.
Options for label
Name Type Description
text string Required. If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` argument will be ignored.
html string Required. If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` argument will be ignored.
for string Required. The value of the for attribute, the id of the input the label is associated with.
isPageHeading boolean Whether the label also acts as the heading for the page.
classes string Classes to add to the label tag.
attributes object HTML attributes (for example data attributes) to add to the label tag.
{% from "checkboxes/macro.njk" import govukCheckboxes %}
{% from "input/macro.njk" import govukInput %}

{% set emailHtml %}
{{ govukInput({
  id: "contact-by-email",
  name: "contact-by-email",
  type: "email",
  classes: "govuk-!-width-one-third",
  label: {
    text: "Email address"
  }
}) }}
{% endset -%}

{% set phoneHtml %}
{{ govukInput({
  id: "contact-by-phone",
  name: "contact-by-phone",
  type: "tel",
  classes: "govuk-!-width-one-third",
  label: {
    text: "Phone number"
  }
}) }}
{% endset -%}

{% set textHtml %}
{{ govukInput({
  id: "contact-by-text",
  name: "contact-by-text",
  type: "tel",
  classes: "govuk-!-width-one-third",
  label: {
    text: "Mobile phone number"
  }
}) }}
{% endset -%}

{{ govukCheckboxes({
  idPrefix: "citizenship-conditional",
  name: "citizen",
  fieldset: {
    legend: {
      text: "How would you like to be contacted?",
      isPageHeading: true,
      classes: "govuk-fieldset__legend--xl"
    }
  },  
  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 you need to add a lot of content, consider showing it on the next page in the process instead.

Error messages

Error messages should be styled like this:

<div class="govuk-form-group govuk-form-group--error">
  <fieldset class="govuk-fieldset" aria-describedby="nationality-hint nationality-error">
    <legend class="govuk-fieldset__legend govuk-fieldset__legend--xl">
      <h1 class="govuk-fieldset__heading">
        What is your nationality?
      </h1>
    </legend>
    <span id="nationality-hint" class="govuk-hint">
      If you have dual nationality, select all options that are relevant to you.
    </span>
    <span id="nationality-error" class="govuk-error-message">
      Select if you are British, Irish or a citizen of a different country
    </span>
    <div class="govuk-checkboxes">
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="nationality-1" name="nationality" type="checkbox" value="british" aria-describedby="nationality-1-item-hint">
        <label class="govuk-label govuk-checkboxes__label" for="nationality-1">
          British
        </label>
        <span id="nationality-1-item-hint" class="govuk-hint govuk-checkboxes__hint">
          including English, Scottish, Welsh and Northern Irish
        </span>
      </div>
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="nationality-2" name="nationality" type="checkbox" value="irish">
        <label class="govuk-label govuk-checkboxes__label" for="nationality-2">
          Irish
        </label>
      </div>
      <div class="govuk-checkboxes__item">
        <input class="govuk-checkboxes__input" id="nationality-3" name="nationality" type="checkbox" value="other">
        <label class="govuk-label govuk-checkboxes__label" for="nationality-3">
          Citizen of another country
        </label>
      </div>
    </div>
  </fieldset>
</div>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
fieldset object Options for the fieldset component (e.g. legend). See fieldset.
hint object Options for the hint component (e.g. text). See hint.
errorMessage object Options for the errorMessage component (e.g. text). See errorMessage.
formGroup object Options for the form-group wrapper See formGroup.
idPrefix string String to prefix id for each checkbox item if no id is specified on each item. If not passed, fall back to using the name option instead.
name string Required. Name attribute for all checkbox items.
items array Required. Array of checkbox items objects. See items.
classes string Classes to add to the checkboxes container.
attributes object HTML attributes (for example data attributes) to add to the anchor tag.
Options for formGroup
Name Type Description
classes string Optional classes to add to the form group (e.g. to show error state for the whole group)
Options for items
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 argument 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 argument will be ignored.
id string Specific id attribute for the checkbox item. If omitted, then idPrefix option will be applied.
name string Required. Specific name for the checkbox item. If omitted, then component global name string will be applied.
value string Required. Value for the checkbox input.
label object Provide attributes and classes to each checkbox item label. See label.
hint object Provide hint to each checkbox item. See hint.
checked boolean If true, checkbox will be checked.
conditional boolean If true, content provided will be revealed when the item is checked.
conditional.html string Provide content for the conditional reveal.
disabled boolean If true, checkbox will be disabled.
attributes object HTML attributes (for example data attributes) to add to the checkbox input tag.
Options for hint
Name Type Description
text string Required. If `html` is set, this is not required. Text to use within the hint. If `html` is provided, the `text` argument will be ignored.
html string Required. If `text` is set, this is not required. HTML to use within the hint. If `html` is provided, the `text` argument will be ignored.
id string Required. Optional id attribute to add to the hint span tag.
classes string Classes to add to the hint span tag.
attributes object HTML attributes (for example data attributes) to add to the hint span tag.
Options for label
Name Type Description
text string Required. If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` argument will be ignored.
html string Required. If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` argument will be ignored.
for string Required. The value of the for attribute, the id of the input the label is associated with.
isPageHeading boolean Whether the label also acts as the heading for the page.
classes string Classes to add to the label tag.
attributes object HTML attributes (for example data attributes) to add to the label tag.
{% from "checkboxes/macro.njk" import govukCheckboxes %}

{{ govukCheckboxes({
  idPrefix: "nationality",
  name: "nationality",
  fieldset: {
    legend: {
      text: "What is your nationality?",
      isPageHeading: true,
      classes: "govuk-fieldset__legend--xl"
    }
  },
  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 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’.

Research on this component

Read a blog post about updates to the radios and checkboxes components.

Get in touch

If you’ve got a question, idea or suggestion share it in #govuk-design-system on cross-government Slack (open in app) or email the Design System team on govuk-design-system-support@digital.cabinet-office.gov.uk

Discuss ‘Checkboxes’ on GitHub