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

Navigation

Pagination

Links to move between pages of a long list.

When to use

  • For search results, news, notices, publications and other long lists.
  • Instead of "Load more" or endless scrolling. Each page is a normal link, so it works without JavaScript, can be bookmarked, and loads only one page of items at a time on slow or costly data.

When not to use

  • To move between steps of a form. Use a "Continue" button.
  • When everything fits on one page. Leave pagination out.
  • To split one article over several pages.

How to use

  • Put it after the list.
  • Show Previous and Next, and numbered pages in between: the first, the last, and a few either side of the current page, with "…" (ggds-pagination__ellipsis) where pages are left out.
  • Leave out Previous on the first page and Next on the last.
  • Above the list, say how many results there are and which ones are showing, such as "Showing 21 to 40 of 236 results".
  • Keep the search and filters in every link: ?q=licence&page=6, not just ?page=6. The Django tag does this for you.
  • Mark the current page with aria-current="page".

Do

  • Use real links with the page in the address.
  • Keep the same number of items on each page.

Don't

  • Lose the visitor's search when they change page.
  • Use buttons and a script to load the next page.

Accessibility

What GGDS does

  • Every link is at least 44px square, and the row wraps on narrow screens.
  • The current page is shown by more than colour: it is filled in, and screen readers announce it as the current page.
  • In the examples and the Django tag, the "…" is hidden from screen readers and Previous and Next carry the hidden word "page".

What you need to do

  • Name the navigation by what is being paged, such as aria-label="Pages of results".
  • Mark the current page with aria-current="page".
  • Give number links a full name, such as aria-label="Page 3".
  • Give Previous and Next hidden text when they are not clear alone, such as "Next page of results".

Example: Pagination

Open this example on its own page

HTML code for “Pagination”
HTML
<nav class="ggds-pagination" aria-label="Pages of results">
  <ul class="ggds-pagination__list">
    <li><a class="ggds-pagination__link" href="?page=2" rel="prev">Previous<span class="ggds-visually-hidden"> page</span></a></li>
    <li><a class="ggds-pagination__link" href="?page=1" aria-label="Page 1">1</a></li>
    <li><a class="ggds-pagination__link" href="?page=2" aria-label="Page 2">2</a></li>
    <li><a class="ggds-pagination__link" href="?page=3" aria-label="Page 3" aria-current="page">3</a></li>
    <li><a class="ggds-pagination__link" href="?page=4" aria-label="Page 4">4</a></li>
    <li class="ggds-pagination__ellipsis" aria-hidden="true">…</li>
    <li><a class="ggds-pagination__link" href="?page=12" aria-label="Page 12">12</a></li>
    <li><a class="ggds-pagination__link" href="?page=4" rel="next">Next<span class="ggds-visually-hidden"> page</span></a></li>
  </ul>
</nav>
JSX (React)
<nav className="ggds-pagination" aria-label="Pages of results">
  <ul className="ggds-pagination__list">
    <li><a className="ggds-pagination__link" href="?page=2" rel="prev">Previous<span className="ggds-visually-hidden"> page</span></a></li>
    <li><a className="ggds-pagination__link" href="?page=1" aria-label="Page 1">1</a></li>
    <li><a className="ggds-pagination__link" href="?page=2" aria-label="Page 2">2</a></li>
    <li><a className="ggds-pagination__link" href="?page=3" aria-label="Page 3" aria-current="page">3</a></li>
    <li><a className="ggds-pagination__link" href="?page=4" aria-label="Page 4">4</a></li>
    <li className="ggds-pagination__ellipsis" aria-hidden="true">…</li>
    <li><a className="ggds-pagination__link" href="?page=12" aria-label="Page 12">12</a></li>
    <li><a className="ggds-pagination__link" href="?page=4" rel="next">Next<span className="ggds-visually-hidden"> page</span></a></li>
  </ul>
</nav>

Use it

Stylesheet
ggds.css includes it. To load only the parts you use: core.css, then components/navigation.css (0.9 KB with gzip, minified), which also holds breadcrumbs, pagination and tab links.
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

No React component: switch the HTML under an example to JSX (React) and copy it.

Django

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

Django template
{% ggds_pagination page_obj %}

Classes and states

Classes for pagination
ClassWhat it does
.ggds-paginationThe <nav>, named after what is being paged.
.ggds-pagination__listThe links, in a row that wraps.
.ggds-pagination__linkPrevious, Next or a page number: at least 44px square.
.ggds-pagination__ellipsisThe "…" between page numbers that are left out.
States of pagination
StateWhat it does
aria-current="page" on .ggds-pagination__linkThe current page: filled in the brand colour.

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: “pagination keeps the search”

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 pagination
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 pagination, newest first
VersionChange
0.2.0Fuller guidance for tags, breadcrumbs, disclosures, the skip link, pagination, rich text, tables and tab links.
0.1.0New: ggds-django, for Django and Django-based CMSs such as Wagtail: the page parts as template tags, a form renderer that turns any Django form into GGDS markup with an error summary and accessible errors, and the GGDS styles, themes and script as static files.
0.1.0Added.

Every change, in What’s new

  • Tab links

    Links that look like tabs, for moving between views of the same section.

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.