Skip to main content

This is a draft (version 0.5.0). The National Information Technology Agency (NITA) plans to make GGDS official guidance for government websites after independent accessibility testing. What this means

Ghana Government Design System Design system for Government of Ghana websites – home Search

Forms

Button

Buttons do things: submit a form, save, continue.

When to use

  • For actions.

When not to use

  • For links to other pages, except one link that starts a task ("Start now").

How to use

  • Use one main (primary) button per page. Use secondary and quiet buttons for other actions, and the warning style only for actions that delete something.

Do

  • Say what will happen: "Send complaint".

Don't

  • Write "Submit" or "Click here".
  • Put two primary buttons side by side.

Accessibility

What GGDS does

  • Buttons are at least 44px tall, with the gold focus ring.
  • The main button's white text is measured against the contrast minimum every time GGDS is built.

What you need to do

  • Use a <button> for actions and a link for going somewhere else.
  • Write what will happen: "Send complaint", not "Submit".
  • Avoid disabled buttons: people cannot find out why they cannot continue. Let them try, and explain what to fix.

Example: Button variants

Open this example on its own page

HTML code for “Button variants”
HTML
<div class="ggds-button-group">
  <button class="ggds-button" type="button">Continue</button>
  <button class="ggds-button ggds-button--secondary" type="button">Save as draft</button>
  <button class="ggds-button ggds-button--quiet" type="button">Cancel</button>
  <button class="ggds-button ggds-button--warning" type="button">Withdraw application</button>
</div>
JSX (React)
<div className="ggds-button-group">
  <button className="ggds-button" type="button">Continue</button>
  <button className="ggds-button ggds-button--secondary" type="button">Save as draft</button>
  <button className="ggds-button ggds-button--quiet" type="button">Cancel</button>
  <button className="ggds-button ggds-button--warning" type="button">Withdraw application</button>
</div>

Open this example on its own page

HTML code for “Link styled as a button (navigation)”
HTML
<a class="ggds-button" href="/services/licence/apply/">Start now</a>
JSX (React)
<a className="ggds-button" href="/services/licence/apply/">Start now</a>

Example: States: normal, focus and disabled

Open this example on its own page

HTML code for “States: normal, focus and disabled”
HTML
<div class="ggds-button-group">
  <button class="ggds-button" type="button">Continue</button>
  <button class="ggds-button ggds-button--secondary" type="button">Save as draft</button>
  <button class="ggds-button ggds-button--quiet" type="button">Cancel</button>
  <button class="ggds-button ggds-button--warning" type="button">Withdraw application</button>
</div>
<div class="ggds-button-group">
  <button class="ggds-button" type="button">Continue</button>
  <button class="ggds-button ggds-button--secondary" type="button">Save as draft</button>
  <button class="ggds-button ggds-button--quiet" type="button">Cancel</button>
  <button class="ggds-button ggds-button--warning" type="button">Withdraw application</button>
</div>
<div class="ggds-button-group">
  <button class="ggds-button" type="button" disabled>Continue</button>
  <button class="ggds-button ggds-button--secondary" type="button" aria-disabled="true">Save as draft</button>
</div>
JSX (React)
<>
  <div className="ggds-button-group">
    <button className="ggds-button" type="button">Continue</button>
    <button className="ggds-button ggds-button--secondary" type="button">Save as draft</button>
    <button className="ggds-button ggds-button--quiet" type="button">Cancel</button>
    <button className="ggds-button ggds-button--warning" type="button">Withdraw application</button>
  </div>
  <div className="ggds-button-group">
    <button className="ggds-button" type="button">Continue</button>
    <button className="ggds-button ggds-button--secondary" type="button">Save as draft</button>
    <button className="ggds-button ggds-button--quiet" type="button">Cancel</button>
    <button className="ggds-button ggds-button--warning" type="button">Withdraw application</button>
  </div>
  <div className="ggds-button-group">
    <button className="ggds-button" type="button" disabled>Continue</button>
    <button className="ggds-button ggds-button--secondary" type="button" aria-disabled="true">Save as draft</button>
  </div>
</>

Use it

Stylesheet
ggds.css includes it. To load only the parts you use: core.css, then components/button.css (0.6 KB with gzip, minified).
JavaScript
None needed.

HTML

Copy the HTML under each example above. It works in any website.

Astro

No Astro component: copy the HTML.

React and Next.js

With @ggds/react:

JavaScript
import { Button, ButtonGroup } from '@ggds/react';

<ButtonGroup>
  <Button type="submit">Continue</Button>
  <Button variant="secondary">Save as draft</Button>
</ButtonGroup>
<Button href="/services/licence/apply/">Start now</Button>

Django

No template tag: copy the HTML into your template.

Classes and states

Classes for button
ClassWhat it does
.ggds-buttonThe main (primary) button: one per page.
.ggds-button--secondaryFor other actions, such as saving a draft.
.ggds-button--quietLooks like a link: for minor actions such as Cancel.
.ggds-button--warningOnly for actions that delete or withdraw something.
.ggds-button-groupButtons side by side, wrapping on narrow screens.
States of button
StateWhat it does
:hoverA darker background.
:focus-visibleThe gold focus ring.
:disabled, aria-disabled="true"Faded, with a not-allowed cursor. Prefer explaining why an action is not available.

Accessibility tests

Automated, on every change

These run each time GGDS changes. A change that fails one is not accepted.

  • WCAG 2.2 A and AA rules (axe), at desktop and phone widths, on every example
  • No sideways scrolling on a 320px screen, also with a wide font, on every example
  • Every approved colour pair meets its contrast minimum, for every institution theme
  • No inline scripts or styles, so it runs under a strict Content Security Policy

By people, with assistive technology

Automated tests find only some of the barriers people meet. These checks are still to be done.

Manual accessibility checks for button
CheckResultNotes
Keyboard onlyNot tested yetWaiting for the external audit with disabled people (decision D-09).
NVDA screen reader with Firefox or Chrome (Windows)Not tested yetWaiting for the external audit with disabled people (decision D-09).
JAWS screen reader with Chrome (Windows)Not tested yetWaiting for the external audit with disabled people (decision D-09).
VoiceOver screen reader with Safari (iPhone)Not tested yetWaiting for the external audit with disabled people (decision D-09).
TalkBack screen reader with Chrome (Android)Not tested yetWaiting for the external audit with disabled people (decision D-09).
Zoom to 400%, and increased text spacingNot tested yetWaiting for the external audit with disabled people (decision D-09).
Windows contrast themes (forced colours)Not tested yetWaiting for the external audit with disabled people (decision D-09).
Voice control (Voice Access or Dragon)Not tested yetWaiting for the external audit with disabled people (decision D-09).

Changes

Changes to button, newest first
VersionChange
0.3.0Button group: space below it, like a form field, so a heading or text after the buttons is not cramped.
0.1.0Added.

Every change, in What’s new

Back to top

Something wrong, unclear or missing? Report a problem with this page or suggest a change to it on GitHub. You need a GitHub account.