Components

Button

<button type="submit" class="govuk-button">
  Save and continue
</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.

Primary options
Name Type Description
element string Whether to use an input, button or a element to create the button. In most cases you will not need to set this as it will be configured automatically if you use href or html.
text string Required. If html is set, this is not required. Text for the button or link. If html is provided, the text argument will be ignored and element will be automatically set to button unless href is also set, or it has already been defined. This argument has no effect if element is set to input.
html string Required. If text is set, this is not required. HTML for the button or link. If html is provided, the text argument will be ignored and element will be automatically set to button unless href is also set, or it has already been defined. This argument has no effect if element is set to input.
name string Required. Name for the input or button. This has no effect on a elements.
type string Required. Type of input or buttonbutton, submit or reset. Defaults to submit. This has no effect on a elements.
value string Required. Value for the button tag. This has no effect on a or input elements.
disabled boolean Whether the button should be disabled. For button and input elements, disabled and aria-disabled attributes will be set automatically.
href string The URL that the button should link to. If this is set, element will be automatically set to a if it has not already been defined.
classes string Classes to add to the button component.
attributes object HTML attributes (for example data attributes) to add to the button component.
{% from "button/macro.njk" import govukButton %}

{{ govukButton({
  text: "Save and continue"
}) }}

When to use this component

Use the button component to help users carry out an action on a GOV.UK page like starting an application or saving their progress.

How it works

Write button text in sentence case, describing the action it performs. For example ‘Save and continue’ or ‘Start now’.

Align the primary action button to the left edge of your form.

There are 2 ways to use the button component. You can use HTML or, if you are using Nunjucks or the GOV.UK Prototype Kit, you can use the Nunjucks macro.

Disabled buttons

Disabled buttons have poor contrast and can confuse some users, so avoid them if possible.

Only use disabled buttons if research shows it makes the user interface easier to understand.

<button type="submit" disabled="disabled" aria-disabled="true" class="govuk-button govuk-button--disabled">
  Disabled button
</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.

Primary options
Name Type Description
element string Whether to use an input, button or a element to create the button. In most cases you will not need to set this as it will be configured automatically if you use href or html.
text string Required. If html is set, this is not required. Text for the button or link. If html is provided, the text argument will be ignored and element will be automatically set to button unless href is also set, or it has already been defined. This argument has no effect if element is set to input.
html string Required. If text is set, this is not required. HTML for the button or link. If html is provided, the text argument will be ignored and element will be automatically set to button unless href is also set, or it has already been defined. This argument has no effect if element is set to input.
name string Required. Name for the input or button. This has no effect on a elements.
type string Required. Type of input or buttonbutton, submit or reset. Defaults to submit. This has no effect on a elements.
value string Required. Value for the button tag. This has no effect on a or input elements.
disabled boolean Whether the button should be disabled. For button and input elements, disabled and aria-disabled attributes will be set automatically.
href string The URL that the button should link to. If this is set, element will be automatically set to a if it has not already been defined.
classes string Classes to add to the button component.
attributes object HTML attributes (for example data attributes) to add to the button component.
{% from "button/macro.njk" import govukButton %}

{{ govukButton({
  text: "Disabled button",
  disabled: true
}) }}

Start buttons

Use a start button as the main call to action on your service’s start page.

<a href="#" role="button" draggable="false" class="govuk-button govuk-button--start">
  Start now
</a>
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.

Primary options
Name Type Description
element string Whether to use an input, button or a element to create the button. In most cases you will not need to set this as it will be configured automatically if you use href or html.
text string Required. If html is set, this is not required. Text for the button or link. If html is provided, the text argument will be ignored and element will be automatically set to button unless href is also set, or it has already been defined. This argument has no effect if element is set to input.
html string Required. If text is set, this is not required. HTML for the button or link. If html is provided, the text argument will be ignored and element will be automatically set to button unless href is also set, or it has already been defined. This argument has no effect if element is set to input.
name string Required. Name for the input or button. This has no effect on a elements.
type string Required. Type of input or buttonbutton, submit or reset. Defaults to submit. This has no effect on a elements.
value string Required. Value for the button tag. This has no effect on a or input elements.
disabled boolean Whether the button should be disabled. For button and input elements, disabled and aria-disabled attributes will be set automatically.
href string The URL that the button should link to. If this is set, element will be automatically set to a if it has not already been defined.
classes string Classes to add to the button component.
attributes object HTML attributes (for example data attributes) to add to the button component.
{% from "button/macro.njk" import govukButton %}

{{ govukButton({
  text: "Start now",
  href: "#",
  classes: "govuk-button--start"
}) }}

Research on this component

If you’ve used this component, get in touch to share your user research findings.

Get in touch

If you’ve got a question, idea or suggestion share it in #govuk-design-system on cross-government Slack (open in app) or email the Design System team on govuk-design-system-support@digital.cabinet-office.gov.uk

Discuss ‘Button’ on GitHub