Button 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 Button 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
text string Required. If html is set, this is not required. Text for the button. If html is provided, the text option will be ignored.
html string Required. If text is set, this is not required. HTML for the button. If html is provided, the text option will be ignored.
type string Type of the button, determining its behaviour in forms – "button", "submit" or "reset". Defaults to "submit". This has no effect if href is set.
name string Name of the button, sent when a form is submitted. This has no effect if href is set.
value string Value of the button, sent when a form is submitted. This has no effect if href is set.
disabled boolean Whether the button should be disabled. disabled and aria-disabled attributes will be set automatically. This has no effect if href is set.
href string The URL that the button should link to.
classes string Classes to add to the button.
attributes object HTML attributes (for example data attributes) to add to the button.
preventDoubleClick boolean Prevent accidental double clicks on submit buttons from submitting forms multiple times. This has no effect if href is set.
isStartButton boolean Use for the main call to action on your service’s start page.
id string The ID of the button.