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 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.
| Name | Type | Description |
|---|---|---|
| aria |
string |
The text for the aria-label which labels the cookie banner region. This region applies to all messages that the cookie banner includes. For example, the cookie message and the confirmation message. Defaults to "Cookie banner".
|
| hidden | boolean |
Defaults to false. If you set this option to true, the whole cookie banner is hidden, including all messages within the banner. You can use hidden for client-side implementations where the cookie banner HTML is present, but hidden until the cookie banner is shown using JavaScript.
|
| classes | string | The additional classes that you want to add to the cookie banner. |
| attributes | object | The additional attributes that you want to add to the cookie banner. For example, data attributes. |
| messages | array | Required. The different messages you can pass into the cookie banner. For example, the cookie message and the confirmation message. See macro options for messages. |
| Name | Type | Description |
|---|---|---|
| heading |
string |
The heading text that displays in the message. You can use any string with this option. If you set headingHtml, headingText is ignored.
|
| heading |
string |
The heading HTML to use within the message. You can use any string with this option. If you set headingHtml, headingText is ignored. If you are not passing HTML, use headingText.
|
| text | string |
Required.
The text for the main content within the message. You can use any string with this option. If you set html, text is not required and is ignored.
|
| html | string |
Required.
The HTML for the main content within the message. You can use any string with this option. If you set html, text is not required and is ignored. If you are not passing HTML, use text.
|
| actions | array |
The buttons and links that you want to display in the message. actions defaults to "button" unless you set href, which renders the action as a link.
See macro options for messages actions.
|
| hidden | boolean |
Defaults to false. If you set it to true, the message is hidden. You can use hidden for client-side implementations where the confirmation message HTML is present, but hidden on the page.
|
| role | string |
Set role to "alert" on confirmation messages to allow assistive tech to automatically read the message. You will also need to move focus to the confirmation message using JavaScript you have written yourself.
|
| classes | string | The additional classes that you want to add to the message. |
| attributes | object | The additional attributes that you want to add to the message. For example, data attributes. |
| Name | Type | Description |
|---|---|---|
| text | string | Required. The button or link text. |
| type | string |
The type of button – "button" or "submit". If href is provided, set type to "button" render a link styled as a button.
|
| href | string |
The href for a link. Set type to "button" and set href to render a link styled as a button.
|
| name | string |
The name attribute for the button. Does not apply if you set href, which makes a link.
|
| value | string |
The value attribute for the button. Does not apply if you set href, which makes a link.
|
| classes | string | The additional classes that you want to add to the button or link. |
| attributes | object | The additional attributes that you want to add to the button or link. For example, data attributes. |