Pagination

Help users navigate forwards and backwards through a series of pages. For example, search results or guidance that’s divided into multiple website pages.

<nav class="asp-pagination">
  <ul class="asp-pagination__list">
    <li class="asp-pagination__item">
      <a href="#">Previous 10 results</a>
    </li>
    <li class="asp-pagination__item asp-pagination__item--next">
      <a href="#">Next 10 results</a>
    </li>
  </ul>
</nav>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Name Type Description
text string or false (boolean) The link text that proceeds, "Next " and "Prev ". Default values are 'default', false (boolean) or null, which will show "10 results".
hrefs array The URLs for the next and/or previous links. See hrefs.

Options for hrefs

Name Type Description
previous string or false (boolean) The URL for the previous link. Default values are false (boolean) or null, which will not show this link. Note, if 'previous' and 'next' are both blank the pagination component will not show.
next string or false (boolean) The URL for the next link. Default values are false (boolean) or null, which will not show this link. Note, if 'previous' and 'next' are both blank the pagination component will not show.
{% from "pagination/macro.njk" import aspPagination %}

{{ aspPagination({
hrefs: {
previous: "#",
next: "#"
}
}) }}

<nav class="asp-pagination">
  <ul class="asp-pagination__list">
    <li class="asp-pagination__item">
      <a href="#">Previous months</a>
    </li>
  </ul>
</nav>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Name Type Description
text string or false (boolean) The link text that proceeds, "Next " and "Prev ". Default values are 'default', false (boolean) or null, which will show "10 results".
hrefs array The URLs for the next and/or previous links. See hrefs.

Options for hrefs

Name Type Description
previous string or false (boolean) The URL for the previous link. Default values are false (boolean) or null, which will not show this link. Note, if 'previous' and 'next' are both blank the pagination component will not show.
next string or false (boolean) The URL for the next link. Default values are false (boolean) or null, which will not show this link. Note, if 'previous' and 'next' are both blank the pagination component will not show.
{% from "pagination/macro.njk" import aspPagination %}

{{ aspPagination({
text: "months",
hrefs: {
previous: "#"
}
}) }}

When to use this component

Consider using pagination when:

  • showing all the content on a single page makes the page take too long to load
  • most users will only need the content on the first page or first few pages

When not to use this component

Only break up content onto separate pages if it improves the performance or usability of your service.

Avoid using the ‘infinite scroll’ technique to automatically load content when the user approaches the bottom of the page. This causes problems for keyboard users.

Do not use this Pagination component for linear journeys — for example, where you’re asking the user to complete a form.

Status of development

The below criteria all need to be met for a component to be considered as fully developed for use within the ASP Digital Design System.

Development criteria Status
WCAG 2.2 compliant Not started
WCAG 2.1 compliant Completed
HTML / Nunjucks version Completed
Figma version Not started
M365 versions Not started
Documentation In progress

Published 3 May 2024
Last updated 11 September 2024