Skip to the content
Konstruktor UI

Navigation

Pagination

Links to the pages of a long list. nav.kui-pagination around a list of page links, with Previous and Next. On a phone the numbers give way to “Page 3 of 12” between the two arrows.

CSS only

Examples

Pages with a gap

Show the first and last page, the current one and its neighbours, and an ellipsis for the gaps. Narrow the window under 640 pixels to see the phone layout.

HTML
<nav class="kui-pagination" aria-label="Invoices, pages">
  <ul>
    <li><a class="kui-pagination__prev" href="#pagination-2"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#chevron-left"></use></svg><span>Previous</span></a></li>
    <li><a href="#pagination-1" aria-label="Page 1">1</a></li>
    <li><a href="#pagination-2" aria-label="Page 2">2</a></li>
    <li><a href="#pagination-3" aria-label="Page 3" aria-current="page">3</a></li>
    <li><a href="#pagination-4" aria-label="Page 4">4</a></li>
    <li><span aria-hidden="true">…</span></li>
    <li><a href="#pagination-12" aria-label="Page 12">12</a></li>
    <li class="kui-pagination__status-item"><span class="kui-pagination__status">Page 3 of 12</span></li>
    <li><a class="kui-pagination__next" href="#pagination-4"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#chevron-right"></use></svg><span>Next</span></a></li>
  </ul>
</nav>

On the first page

There is no previous page, so Previous is an <a> without href and with aria-disabled="true": it shows, it cannot be reached or pressed.

HTML
<nav class="kui-pagination" aria-label="Search results, pages">
  <ul>
    <li><a class="kui-pagination__prev" aria-disabled="true"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#chevron-left"></use></svg><span>Previous</span></a></li>
    <li><a href="#pagination-f1" aria-label="Page 1" aria-current="page">1</a></li>
    <li><a href="#pagination-f2" aria-label="Page 2">2</a></li>
    <li><a href="#pagination-f3" aria-label="Page 3">3</a></li>
    <li class="kui-pagination__status-item"><span class="kui-pagination__status">Page 1 of 3</span></li>
    <li><a class="kui-pagination__next" href="#pagination-f2"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#chevron-right"></use></svg><span>Next</span></a></li>
  </ul>
</nav>

States

Every state

Current: filled with the text colour, aria-current="page". Hover: a soft fill and a line. Focus: the ring. Disabled: faded and not reachable. The ellipsis is hidden from screen readers.

HTML
<nav class="kui-pagination" aria-label="States, pages">
  <ul>
    <li><a class="kui-pagination__prev" aria-disabled="true"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#chevron-left"></use></svg><span>Disabled</span></a></li>
    <li><a href="#pagination-s1" aria-label="Page 1" aria-current="page">1</a></li>
    <li><a href="#pagination-s2" aria-label="Page 2">2</a></li>
    <li><span aria-hidden="true">…</span></li>
    <li><a href="#pagination-s99" aria-label="Page 1 248">1 248</a></li>
    <li class="kui-pagination__status-item"><span class="kui-pagination__status">Page 1 of 1 248</span></li>
    <li><a class="kui-pagination__next" href="#pagination-s2"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#chevron-right"></use></svg><span>Next</span></a></li>
  </ul>
</nav>

Classes and attributes

nav.kui-pagination
The landmark; give it an aria-label that names the list.
ul > li > a
A page link with aria-label="Page N". aria-current="page" marks the current page.
.kui-pagination__prev, .kui-pagination__next
The links to the previous and next page, with an icon and a word.
a[aria-disabled="true"]
A Previous or Next that does not apply: no href, so it is not reachable.
span[aria-hidden="true"]
The ellipsis for skipped pages.
.kui-pagination__status-item, .kui-pagination__status
“Page 3 of 12”: shown only under 640 pixels, where the numbers hide and Previous and Next show only their arrows (their words stay for screen readers).

Keyboard

Tab
Moves through Previous, the page links and Next.
Enter
Opens the page.

Accessibility

  • A <nav> with a name such as “Invoices, pages”, so it is not confused with the main navigation.
  • Each number has aria-label="Page N"; a bare “3” is not a clear link name.
  • The current page has aria-current="page".
  • Previous and Next have words, not only arrows.
  • After moving to another page, put focus at the start of the list or its heading, not at the top of the document.

Do and do not

Do

  • Use links with real addresses (?page=3), so a page can be shared and the back button works.
  • Keep the first and last page visible.
  • Say how many results there are near the list.

Do not

  • Do not show every page number of a long list.
  • Do not use pagination for a feed a person reads from top to bottom; load more on request instead.
  • Do not move the buttons when the numbers change width.