Button
<button class="button button--start" type=submit>Start button. modifier: start</button>
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.
Name | Type | Description |
---|---|---|
modifier | string | Required. Default values are 'start' (green), 'primary' (blue) and 'warning' (red). |
type | string or false (boolean) | The button component type. Default values are 'button', 'submit', 'reset', false (boolean) or null. If 'type' is provided, the 'href' parameter will be ignored. Default values are false (boolean) or null. |
disabled | boolean | Whether the button component is disabled. Default values are false (boolean), true (boolean) or null. If 'type' is not provided, the 'disabled' parameter will be ignored. |
href | string or false (boolean) | The URL for the button component. If 'type' is provided, the 'href' parameter will be ignored. Default values are false (boolean) or null. |
html | string | Required. The button component content. If 'html' is provided, the 'text' parameter will be ignored. |
text | string | Required. The button component content. If 'html' is provided, the 'text' parameter will be ignored. |
{% from "button/macro.njk" import aspButton %}
{{ aspButton({
modifier: "start",
type: "submit",
text: "Start button. modifier: start"
}) }}
Button with link
<button class="button button--start" href=#>Start button as a link. modifier: start</button>
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.
Name | Type | Description |
---|---|---|
modifier | string | Required. Default values are 'start' (green), 'primary' (blue) and 'warning' (red). |
type | string or false (boolean) | The button component type. Default values are 'button', 'submit', 'reset', false (boolean) or null. If 'type' is provided, the 'href' parameter will be ignored. Default values are false (boolean) or null. |
disabled | boolean | Whether the button component is disabled. Default values are false (boolean), true (boolean) or null. If 'type' is not provided, the 'disabled' parameter will be ignored. |
href | string or false (boolean) | The URL for the button component. If 'type' is provided, the 'href' parameter will be ignored. Default values are false (boolean) or null. |
html | string | Required. The button component content. If 'html' is provided, the 'text' parameter will be ignored. |
text | string | Required. The button component content. If 'html' is provided, the 'text' parameter will be ignored. |
{% from "button/macro.njk" import aspButton %}
{{ aspButton({
modifier: "start",
href: "#",
text: "Start button as a link. modifier: start"
}) }}
When to use this component
Use the button component to help users carry out an action like starting an application or saving their information.
How it works
Write button text in sentence case, describing the action it performs. For example:
- ‘Start now’ at the start of the service
- ‘Send sign in details’ to an account a user has already created
- ‘Log out’ when a user is signed in to an account
You may need to include more or different words to better describe the action. For example, ‘Send sign in details’.
Align the primary action button to the left edge of your form.
Secondary buttons
Use secondary buttons for secondary calls to action on a page.
Pages with too many calls to action make it hard for users to know what to do next. Before adding lots of secondary buttons, try to simplify the page or break the content down across multiple pages.
<button class="button button--primary" type=button>Primary button. modifier: primary</button>
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.
Name | Type | Description |
---|---|---|
modifier | string | Required. Default values are 'start' (green), 'primary' (blue) and 'warning' (red). |
type | string or false (boolean) | The button component type. Default values are 'button', 'submit', 'reset', false (boolean) or null. If 'type' is provided, the 'href' parameter will be ignored. Default values are false (boolean) or null. |
disabled | boolean | Whether the button component is disabled. Default values are false (boolean), true (boolean) or null. If 'type' is not provided, the 'disabled' parameter will be ignored. |
href | string or false (boolean) | The URL for the button component. If 'type' is provided, the 'href' parameter will be ignored. Default values are false (boolean) or null. |
html | string | Required. The button component content. If 'html' is provided, the 'text' parameter will be ignored. |
text | string | Required. The button component content. If 'html' is provided, the 'text' parameter will be ignored. |
{% from "button/macro.njk" import aspButton %}
{{ aspButton({
modifier: "primary",
type: "button",
text: "Primary button. modifier: primary"
}) }}
Warning buttons
Warning buttons are designed to make users think carefully before they use them. They only work if used very sparingly. Most services should not need one.
<button class="button button--warning" type=reset>Warning button. modifier: warning</button>
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.
Name | Type | Description |
---|---|---|
modifier | string | Required. Default values are 'start' (green), 'primary' (blue) and 'warning' (red). |
type | string or false (boolean) | The button component type. Default values are 'button', 'submit', 'reset', false (boolean) or null. If 'type' is provided, the 'href' parameter will be ignored. Default values are false (boolean) or null. |
disabled | boolean | Whether the button component is disabled. Default values are false (boolean), true (boolean) or null. If 'type' is not provided, the 'disabled' parameter will be ignored. |
href | string or false (boolean) | The URL for the button component. If 'type' is provided, the 'href' parameter will be ignored. Default values are false (boolean) or null. |
html | string | Required. The button component content. If 'html' is provided, the 'text' parameter will be ignored. |
text | string | Required. The button component content. If 'html' is provided, the 'text' parameter will be ignored. |
{% from "button/macro.njk" import aspButton %}
{{ aspButton({
modifier: "warning",
type: "reset",
text: "Warning button. modifier: warning"
}) }}
Status of development
The below criteria all need to be met for a component to be considered as fully developed for use within the ASP Digital Design System.
Development criteria | Status |
---|---|
WCAG 2.2 compliant | Not started |
WCAG 2.1 compliant | Completed |
HTML / Nunjucks version | Completed |
Figma version | Not started |
M365 versions | Not started |
Documentation | In progress |
Published 3 May 2024
Last updated 11 September 2024