Checkboxes
Nunjucks macro options
Use options to customise the appearance, content and behaviour of this component when using a macro, for example, changing the text.
Also see the guidance on the Checkboxes component page, which shows these options in use within each example.
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.
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.
|
| 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.
|
| 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 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.
|