Radios 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 Radios 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
Name Type Description
fieldset object The fieldset used by the radios component. See macro options for fieldset.
hint object Can be used to add a hint to the radios component. See macro options for hint.
errorMessage object Can be used to add an error message to the radios component. The error message component will not display if you use a falsy value for errorMessage, for example false or null. See macro options for errorMessage.
formGroup object Additional options for the form group containing the radios component. See macro options for formGroup.
idPrefix string Optional prefix. This is used to prefix the id attribute for each radio input, hint and error message, separated by -. Defaults to the name option value.
name string Required. Name attribute for the radio items.
items array Required. The radio items within the radios component. See macro options for items.
value string The value for the radio which should be checked when the page loads. Use this as an alternative to setting the checked option on each individual item.
classes string Classes to add to the radio container.
attributes object HTML attributes (for example data attributes) to add to the radio container.
Options for formGroup object
Name Type Description
classes string Classes to add to the form group (for example to show error state for the whole group).
attributes object HTML attributes (for example data attributes) to add to the form group.
beforeInputs object Content to add before all radio items within the radios component. See macro options for formGroup beforeInputs.
afterInputs object Content to add after all radio items within the radios component. See macro options for formGroup afterInputs.
Options for formGroup beforeInputs object
Name Type Description
text string Required. Text to add before all radio items. If html is provided, the text option will be ignored.
html string Required. HTML to add before all radio items. If html is provided, the text option will be ignored.
Options for formGroup afterInputs object
Name Type Description
text string Required. Text to add after all radio items. If html is provided, the text option will be ignored.
html string Required. HTML to add after all radio items. If html is provided, the text option will be ignored.
Options for items array objects
Name Type Description
text string Required. If html is set, this is not required. Text to use within each radio item label. If html is provided, the text option will be ignored.
html string Required. If text is set, this is not required. HTML to use within each radio item label. If html is provided, the text option will be ignored.
id string Specific ID attribute for the radio item. If omitted, then idPrefix string will be applied.
value string Required. Value for the radio input.
label object Subset of options for the label used by each radio item within the radios component. See macro options for items label.
hint object Can be used to add a hint to each radio item within the radios component. See macro options for hint.
divider string Divider text to separate radio items, for example the text "or".
checked boolean Whether the radio should be checked when the page loads. Takes precedence over the top-level value option.
conditional object Provide additional content to reveal when the radio is checked. See macro options for items conditional.
disabled boolean If true, radio will be disabled.
attributes object HTML attributes (for example data attributes) to add to the radio input tag.
Options for items label component
Name Type Description
classes string Classes to add to the label tag.
attributes object HTML attributes (for example data attributes) to add to the label tag.
Options for items conditional object
Name Type Description
html string Required. The HTML to reveal when the radio is checked.
Options for hint component
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 option 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 option will be ignored.
id string 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.