Component
Pagination
Published on
Description
The Pagination component links to the previous page, the next page, and numbered pages of a long list of results. It renders plain links, so it works without JavaScript.
Pass current, total, and href. href is a template such as ?page={n} or a function that takes a page number and returns a URL. Long ranges collapse to the first page, the last page, and the pages either side of the current one.
Previous is left out on the first page and Next on the last page. Change the text with labelPrevious, labelNext, and labelPage.
Example
Accessibility
- The links sit in a
<nav aria-label="Pagination">landmark, so screen reader users can jump to it. - The current page link has
aria-current="page", and is bold and underlined. - Numbered links include visually hidden text, so they read as "Page 2" instead of "2".
- Previous and Next carry
rel="prev"andrel="next". Missing ones are left out, never shown as disabled links. - Every link is at least 44 by 44 CSS pixels.
References
- Pagination(opens in new tab) — GOV.UK Design System
- Understanding Target Size (Enhanced)(opens in new tab) — W3C
Related
- Links — for general-purpose navigation
Variables
None