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

Dialog

A box over the page that asks people to confirm something before it happens, such as deleting a draft.

When to use

  • To confirm an action that cannot be undone, such as deleting a draft application or withdrawing one.
  • For the timeout warning.

When not to use

  • For anything people need to read carefully, fill in or come back to: use a page.
  • For messages: use a notice on the page. A dialog interrupts people, and some find it hard to use with a screen magnifier.

How to use

  • Make the opener a link to a confirmation page, so it works without JavaScript, and add data-ggds-dialog="<the dialog's id>". With the GGDS script, the link opens the dialog instead.
  • Use the browser's <dialog> with class="ggds-dialog" and aria-labelledby naming its heading.
  • Ask a question as the heading ("Delete this draft?") and say what will happen. Name the action on the button ("Delete draft", not "OK"), and give a way out ("Cancel") with data-ggds-dialog-close.
  • Put the action in a form that posts, inside the dialog, so the server does it, as on the confirmation page.
  • Use ggds-dialog--warning for an action that cannot be undone.

Accessibility

What GGDS does

  • The browser keeps focus inside the dialog, makes the page behind it unavailable, closes it with Escape and returns focus to the link that opened it.
  • Focus starts on the first button, which is never the action that cannot be undone.
  • Without JavaScript, the link opens the confirmation page.

What you need to do

  • Keep it short: a heading, a sentence and two buttons.
  • Put the safe choice first, so it gets focus.

Example: Confirm before deleting

Open this example on its own page

HTML code for “Confirm before deleting”
HTML
<p>Draft saved on 12 November 2026.</p>
<a class="ggds-button ggds-button--warning" href="#delete-draft-page" data-ggds-dialog="delete-draft">Delete draft</a>
<dialog class="ggds-dialog ggds-dialog--warning" id="delete-draft" aria-labelledby="delete-draft-title">
  <h2 class="ggds-dialog__title" id="delete-draft-title">Delete this draft?</h2>
  <div class="ggds-dialog__body"><p>Your answers will be deleted. You cannot get them back.</p></div>
  <form class="ggds-dialog__actions" action="#delete-draft-page" method="post">
    <button class="ggds-button ggds-button--secondary" type="button" data-ggds-dialog-close>Cancel</button>
    <button class="ggds-button ggds-button--warning" type="submit">Delete draft</button>
  </form>
</dialog>
JSX (React)
<>
  <p>Draft saved on 12 November 2026.</p>
  <a className="ggds-button ggds-button--warning" href="#delete-draft-page" data-ggds-dialog="delete-draft">Delete draft</a>
  <dialog className="ggds-dialog ggds-dialog--warning" id="delete-draft" aria-labelledby="delete-draft-title">
    <h2 className="ggds-dialog__title" id="delete-draft-title">Delete this draft?</h2>
    <div className="ggds-dialog__body"><p>Your answers will be deleted. You cannot get them back.</p></div>
    <form className="ggds-dialog__actions" action="#delete-draft-page" method="post">
      <button className="ggds-button ggds-button--secondary" type="button" data-ggds-dialog-close>Cancel</button>
      <button className="ggds-button ggds-button--warning" type="submit">Delete draft</button>
    </form>
  </dialog>
</>

Use it

Stylesheet
ggds.css includes it. To load only the parts you use: core.css, then components/dialog.css (0.6 KB with gzip, minified).
JavaScript
Needed to open it: @ggds/js turns the link into a button that opens the dialog, and closes it with data-ggds-dialog-close. Without it, the link goes to a confirmation page.

HTML

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

Astro

With @ggds/astro:

JavaScript
import Dialog from '@ggds/astro/Dialog.astro';

---
import Dialog from '@ggds/astro/Dialog.astro';
---
<a class="ggds-button ggds-button--warning" href="/drafts/delete/" data-ggds-dialog="delete-draft">Delete draft</a>
<Dialog id="delete-draft" title="Delete this draft?" warning action="/drafts/delete/">
  <p>Your answers will be deleted. You cannot get them back.</p>
  <button slot="actions" class="ggds-button ggds-button--warning" type="submit">Delete draft</button>
</Dialog>  {/* Cancel comes first */}

React and Next.js

With @ggds/react:

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

{/* Cancel comes first, and closes it */}
<Dialog id="delete-draft" open={open} onClose={() => setOpen(false)} warning
  title="Delete this draft?" action="/drafts/delete/"
  actions={<Button variant="warning" type="submit">Delete draft</Button>}>
  <p>Your answers will be deleted. You cannot get them back.</p>
</Dialog>

Django

With ggds-django ({% load ggds %}):

Django template
{% load ggds %}
{% ggds_dialog id="delete-draft" title="Delete this draft?" body="Your answers will be deleted." action="/drafts/delete/" confirm="Delete draft" warning=True %}

Classes and states

Classes for dialog
ClassWhat it does
.ggds-dialogOn a <dialog>: a box over the page, opened as a modal.
.ggds-dialog--warningFor an action that cannot be undone: an orange line at the top.
.ggds-dialog__titleThe heading, named by the dialog's aria-labelledby.
.ggds-dialog__bodyWhat will happen.
.ggds-dialog__actionsThe buttons, the safe one first.
States of dialog
StateWhat it does
[open]The dialog is showing, over a darkened page.

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
  • Behaviour test: “dialog: the link opens it, Escape and Cancel close it, and focus goes back to the link”

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 dialog
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 dialog, newest first
VersionChange
0.4.0New components for services that take people from start to payment, in HTML, React, Astro and Django, each checked element by element against its documentation example and with axe on phones and computers. All are alpha.
0.1.0Added.

Every change, in What’s new

  • Button

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

  • Timeout warning

    Warns people before they are signed out for being inactive, and lets them stay signed in with one button.

  • Notice

    A message box for information, success, a warning or danger, and an urgent notice for the whole site.

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.