Button
New WCAG 2.2 criteria affect this component
To use the ‘Button’ and meet the new Web Content Accessibility Guidelines (WCAG) 2.2 criteria, make sure that users can successfully:
See the full list of components and patterns affected by WCAG 2.2.
<button type="submit" class="govuk-button" data-module="govuk-button">
Save and continue
</button>
{% from "govuk/components/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 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
- ‘Sign in’ to an account a user has already created
- ‘Continue’ when the service does not save a user’s information
- ‘Save and continue’ when the service does save a user’s information
- ‘Save and come back later’ when a user can save their information and come back later
- ‘Add another’ to add another item to a list or group
- ‘Pay’ to make a payment
- ‘Confirm and send’ on a check answers page that does not have any legal content a user must agree to
- ‘Accept and send’ on a check answers page that has legal content a user must agree to
- ‘Sign 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, ‘Add another address’ and ‘Accept and claim a tax refund’.
Align the primary action button to the left edge of your form.
Do not decrease the height or target area of buttons. This is to make sure users can easily interact with buttons. This is to comply with WCAG 2.2 success criterion 2.5.8 Target size (minimum).
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.
Default buttons
Use a default button for the main call to action on a page.
Avoid using multiple default buttons on a single page. Having more than one main call to action reduces their impact, and makes it harder for users to know what to do next.
<button type="submit" class="govuk-button" data-module="govuk-button">
Save and continue
</button>
{% from "govuk/components/button/macro.njk" import govukButton %}
{{ govukButton({
text: "Save and continue"
}) }}
Start buttons
Use a start button for the main call to action on your service’s start page.
Start buttons do not usually submit form data, so use a link tag instead of a button tag.
<a href="#" role="button" draggable="false" class="govuk-button govuk-button--start" data-module="govuk-button">
Start now
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
</svg>
</a>
{% from "govuk/components/button/macro.njk" import govukButton %}
{{ govukButton({
text: "Start now",
href: "#",
isStartButton: true
}) }}
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 type="submit" class="govuk-button govuk-button--secondary" data-module="govuk-button">
Find address
</button>
{% from "govuk/components/button/macro.njk" import govukButton %}
{{ govukButton({
text: "Find address",
classes: "govuk-button--secondary"
}) }}
You can also group default and secondary buttons together.
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 type="submit" class="govuk-button govuk-button--warning" data-module="govuk-button">
Delete account
</button>
{% from "govuk/components/button/macro.njk" import govukButton %}
{{ govukButton({
text: "Delete account",
classes: "govuk-button--warning"
}) }}
Only use warning buttons for actions with serious destructive consequences that cannot be easily undone by a user. For example, permanently deleting an account.
When letting users carry out an action like this, it’s a good idea to include an additional step which asks them to confirm it.
In this instance, use another style of button for the initial call to action, and a warning button for the final confirmation.
Do not only rely on the red colour of a warning button to communicate the serious nature of the action. This is because not all users will be able to see the colour or will understand what it signifies. Make sure the context and button text make clear what will happen if the user selects it.
Buttons on dark backgrounds
Use the govuk-button--inverse
modifier class to show white buttons on dark backgrounds – for example, in headers, custom components, and patterns with darker backgrounds.
Make sure all users can see the button – the white button and background colour must have a contrast ratio of at least 3:1.
<button type="submit" class="govuk-button govuk-button--inverse" data-module="govuk-button">
Create an account
</button>
{% from "govuk/components/button/macro.njk" import govukButton %}
{{ govukButton({
text: "Create an account",
classes: "govuk-button--inverse"
}) }}
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 aria-disabled="true" class="govuk-button" data-module="govuk-button">
Disabled button
</button>
{% from "govuk/components/button/macro.njk" import govukButton %}
{{ govukButton({
text: "Disabled button",
disabled: true
}) }}
Grouping buttons
Use a button group when two or more buttons are placed together.
<div class="govuk-button-group">
<button type="submit" class="govuk-button" data-module="govuk-button">
Save and continue
</button>
<button type="submit" class="govuk-button govuk-button--secondary" data-module="govuk-button">
Save as draft
</button>
</div>
{% from "govuk/components/button/macro.njk" import govukButton %}
<div class="govuk-button-group">
{{ govukButton({
text: "Save and continue"
}) }}
{{ govukButton({
text: "Save as draft",
classes: "govuk-button--secondary"
}) }}
</div>
Any links within a button group will automatically align with the buttons.
<div class="govuk-button-group">
<button type="submit" class="govuk-button" data-module="govuk-button">
Continue
</button>
<a class="govuk-link" href="#">Cancel</a>
</div>
{% from "govuk/components/button/macro.njk" import govukButton %}
<div class="govuk-button-group">
{{ govukButton({
text: "Continue"
}) }}
<a class="govuk-link" href="#">Cancel</a>
</div>
Stop users from accidentally sending information more than once
Sometimes, users double click buttons because they:
- have used operating systems where they have to double click items to make them work
- are experiencing a slow connection which means they are not given feedback on their action quickly enough
- have motor impairments such as hand tremors which cause them to click the button involuntarily
In some cases, this can mean their information is sent twice.
For example, the GOV.UK Notify team discovered that a number of users were receiving invitations twice, because the person sending them was double clicking the ‘send’ button.
If you are working in production and research shows that users are frequently sending information twice, you can configure the button to ignore the second click.
To do this, set the data-prevent-double-click
attribute to true
. You can do this directly in the HTML or, if you’re using Nunjucks, you can use the Nunjucks macro as shown in this example.
<button type="submit" data-prevent-double-click="true" class="govuk-button" data-module="govuk-button">
Confirm and send
</button>
{% from "govuk/components/button/macro.njk" import govukButton %}
{{ govukButton({
text: "Confirm and send",
preventDoubleClick: true
}) }}
This feature will prevent double clicks for users that have JavaScript enabled, however you should also think about the issue server-side to protect against attacks.
In the case of slow connections, aim to give the user information about what’s happening, for example, by showing a loading spinner or a modal, before using data-prevent-double-click
.
Research on this component
Testing on GOV.UK has shown that the green colour of start buttons has improved click-through rates.
Help improve this component
To help make sure that this page is useful, relevant and up to date, you can:
- take part in the ‘Button’ discussion on GitHub and share your research
- propose a change – read more about how to propose changes in GitHub
Tell us if your service uses this component
Take part in our usage survey (opens in a new tab) to help us improve this component to better meet the needs of the services that use it.
Need help?
If you’ve got a question about the GOV.UK Design System, contact the team.