Skip to main content

These components are for prototyping the GOV.UK app, not for use in production.

<govuk-app-button>

Button

Lets the user take an action, such as continuing a journey, confirming a choice or removing something. It is the app's own button, in five variants: primary, secondary, grouped secondary, compact and destructive, and a sixth, black, for a green screen.

GOV.UK app component

Examples

Primary

Continue Continue

HTML

<govuk-app-button name="continue">Continue</govuk-app-button>

Primary, disabled until there is something to confirm

Confirm postcode Confirm postcode

HTML

<govuk-app-button disabled>Confirm postcode</govuk-app-button>

Submit, sending a form

Confirm postcode
Confirm postcode

HTML

<form>
  <govuk-app-stack gap="large">
    <govuk-app-text-field type="postcode" name="postcode" label="Postcode" hint="For example SW1A 2AA"></govuk-app-text-field>
    <govuk-app-button type="submit">Confirm postcode</govuk-app-button>
  </govuk-app-stack>
</form>

Secondary

Select your address instead Select your address instead

HTML

<govuk-app-button variant="secondary">Select your address instead</govuk-app-button>

Grouped secondary, under a primary button

Continue Skip Continue Skip

HTML

<govuk-app-button name="continue">Continue</govuk-app-button>
<govuk-app-button variant="grouped-secondary" name="skip">Skip</govuk-app-button>

Compact

Add a vehicle Add a vehicle

HTML

<govuk-app-button variant="compact">Add a vehicle</govuk-app-button>

Destructive

Remove account Remove account

HTML

<govuk-app-button variant="destructive" name="remove">Remove account</govuk-app-button>

Destructive, disabled

Remove account Remove account

HTML

<govuk-app-button variant="destructive" disabled>Remove account</govuk-app-button>

Black

Continue Continue

HTML

<govuk-app-button variant="black" name="continue">Continue</govuk-app-button>

Inputs

Attributes
Attribute Type Default Description
variant "primary" | "secondary" | "grouped-secondary" | "compact" | "destructive" | "black" primary Which kind of button. black: the main action on a green screen. Anything else draws a primary button.
type "button" | "submit" button submit: pressing it sends the form it's in, with what the user typed or chose, and its own name and value if it has them. button: it does nothing until a page listens for it.
disabled boolean false Greys the button out, and stops it being pressed or focused.
name string Set on the button, so a page listening for clicks can tell one button from another.
value string Set on the button, alongside name, to say which of several choices was pressed.

Content

The button's label, as text. Keep it to a few words.

Outputs

  • click: From the <button> it draws, when it is pressed, and not when it is disabled. It bubbles, so a page can listen once for every button and use event.target.closest('button').name and .value to tell which was pressed.
  • submit: From the form a submit button is in, when it is pressed. A page can stop the form being sent with event.preventDefault() and read its answers with new FormData(event.target, event.submitter), which includes the button's own name and value.

Rules

  • Use a primary button for the main action on a screen, and use at most one.
  • Use a grouped secondary button for an alternative to the primary action, directly below it in the same group, as ButtonStackView does.
  • Use a secondary button, with its outline, for an alternative action that stands on its own, away from a primary button.
  • Use a compact button for a lighter action within the content of a screen, such as on a card, rather than to move the journey on.
  • Use a destructive button only for an action that deletes or removes something, such as signing out or removing an account, and usually on a screen that asks the user to confirm it.
  • Use a black button in place of a primary button on a green screen, as the app does, and not elsewhere.
  • Write the label as a verb that says what will happen: 'Continue', 'Confirm postcode', 'Remove account'. Do not use 'Click here' or 'Submit'.
  • Make the button that sends a form's answers a submit button, inside the form, so pressing Return in a field sends them too.
  • A button fills the width of what it sits in. Put it in a container to make it narrower.
  • Disable a button only while the screen is waiting for something the user has to give first, such as a postcode, and make it clear what that is.

When not to use it

When Use instead
For an action on the whole screen, such as Close, Done or Edit govuk-app-nav-bar-item
For a screen's main action and a way out of it, at the bottom of the screen govuk-app-button-stack
For a row that goes to another screen, as on Settings govuk-app-grouped-list-row type="navigation"
For a link to a web page govuk-app-grouped-list-row type="link"
For an action that adds to a list, such as Add vehicle govuk-app-grouped-list-row type="action"
For a few less-used actions on a card, such as Change address govuk-app-menu-button
To switch something on or off straight away govuk-app-grouped-list-row type="toggle"

Sources

The iOS, Android and Figma sources it was built from
  • iOS: GOVUKButton in govuk-once/govuk-mobile-ios-gov-kit/GovKitUI/Sources/Components/Buttons/GOVUKButton.swift at ad8590b
  • iOS: ButtonConfiguration .primary, .secondary, .groupedSecondary, .compact, .destructive in govuk-once/govuk-mobile-ios-gov-kit/GovKitUI/Sources/Components/Buttons/ButtonConfiguration+Convenience.swift at ad8590b
  • iOS: SwiftUIButton in govuk-once/govuk-mobile-ios-gov-kit/GovKitUI/Sources/Components/Buttons/SwiftUIButton.swift at ad8590b
  • iOS: ButtonStackView in govuk-once/govuk-mobile-ios-app/Production/govuk_ios/SwiftUIViews/ButtonStackView.swift at 1e520fc1
  • iOS: ButtonConfiguration .blackPrimaryButton in govuk-once/govuk-mobile-ios-app/Production/govuk_ios/Extensions/GovKit/ButtonConfiguration+Convenience.swift at fc2b3b1d
  • Android: PrimaryButton, SecondaryButton, CompactButton, DestructiveButton in govuk-once/govuk-mobile-android-app/design/src/main/kotlin/uk/gov/govuk/design/ui/component/Button.kt at 16621861
  • Android: DoubleButtonGroup, FixedPrimaryButton in govuk-once/govuk-mobile-android-app/design/src/main/kotlin/uk/gov/govuk/design/ui/component/ButtonGroup.kt at 16621861
  • Android: AccountConnectionButton in govuk-once/govuk-mobile-android-app/design/src/main/kotlin/uk/gov/govuk/design/ui/component/Button.kt at 9952400f
  • Figma: none linked yet
  • The button in the app prototyping system's kit (PR #64)

In the app

Screenshots of the app's own component, to compare the examples with

iOS

iOS app: Primary: default, pressed, disabled, focused
Primary: default, pressed, disabled, focused
iOS app: Secondary: default, pressed, disabled, focused
Secondary: default, pressed, disabled, focused
iOS app: Grouped secondary: default, pressed, disabled, focused
Grouped secondary: default, pressed, disabled, focused
iOS app: Compact: default, pressed, disabled, focused
Compact: default, pressed, disabled, focused
iOS app: Destructive: default, pressed, disabled, focused
Destructive: default, pressed, disabled, focused

Android

Android app: Primary
Primary
Android app: Secondary
Secondary
Android app: Compact
Compact
Android app: Destructive
Destructive