Pagination provides a clear way for users to navigate through content or data split across multiple pages.
The vf-pagination component helps users focus on a manageable set of content at a time and gives users the controls to move across the pages in any order (non-linear navigation). It commonly appears below the content it controls, after the final item in the list. The placement could vary in some use cases. Pagination is often used for search results, listings and tables.
vf-button with clear labels to let users move to the next or previous page.The pagination component provides options that can be used to provide the navigation experience that best fits different use cases.
The default pagination component shows Previous (<) and Next (>) navigation controls alongside a set of numbered page links.
This variant extends the navigation controls of the default by adding “Jump to first page” (<<) and “Jump to last page” (>>) buttons.
Landmarks and naming
Current page
Touch targets
Link/button labelling
Keyboard interaction
Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
includeYou'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"exampleMultiColumns" : "false",
"component-type" : "block",
"previous_text" : "Previous",
"previous_url" : "JavaScript:Void(0);",
"next_text" : "Next",
"next_url" : "JavaScript:Void(0);",
"jumpBack_text" : -10,
"jumpBack_url" : "JavaScript:Void(0);",
"jumpForward_text" : 10,
"jumpForward_url" : "JavaScript:Void(0);",
"pagination__list" : [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],
}
%}
{% include "../path_to/vf-pagination/vf-pagination.njk" %}
renderThis approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
{% render '@vf-pagination', {
"exampleMultiColumns" : "false",
"component-type" : "block",
"previous_text" : "Previous",
"previous_url" : "JavaScript:Void(0);",
"next_text" : "Next",
"next_url" : "JavaScript:Void(0);",
"jumpBack_text" : -10,
"jumpBack_url" : "JavaScript:Void(0);",
"jumpForward_text" : 10,
"jumpForward_url" : "JavaScript:Void(0);",
"pagination__list" : [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],}
%}
<nav class="vf-pagination" aria-label="Pagination">
<ul class="vf-pagination__list">
<li class="vf-pagination__item vf-pagination__item--jump-back">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="First page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M13.5 5.5L8.5 10.5L13.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M9.5 5.5L4.5 10.5L9.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">First page</span>
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--previous-page">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="Previous page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M11.5 5.5L6.5 10.5L11.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">Previous page</span>
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>1
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>2
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>3
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--is-active">
<span class="vf-pagination__label" aria-current="page">
<span class="vf-u-sr-only">Page </span>4
</span>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>5
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--next-page">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="Next page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M8.5 5.5L13.5 10.5L8.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">Next page</span>
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--jump-forward">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="Last page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M6.5 5.5L11.5 10.5L6.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M10.5 5.5L15.5 10.5L10.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">Last page</span>
</a>
</li>
</ul>
</nav>
Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
includeYou'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"exampleMultiColumns" : "false",
"component-type" : "block",
"previous_text" : "Previous",
"previous_url" : "JavaScript:Void(0);",
"next_text" : "Next",
"next_url" : "JavaScript:Void(0);",
"jumpBack_text" : -10,
"jumpBack_url" : "JavaScript:Void(0);",
"jumpForward_text" : 10,
"jumpForward_url" : "JavaScript:Void(0);",
"pagination__list" : [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],
}
%}
{% include "../path_to/vf-pagination/vf-pagination.njk" %}
renderThis approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
{% render '@vf-pagination', {
"exampleMultiColumns" : "false",
"component-type" : "block",
"previous_text" : "Previous",
"previous_url" : "JavaScript:Void(0);",
"next_text" : "Next",
"next_url" : "JavaScript:Void(0);",
"jumpBack_text" : -10,
"jumpBack_url" : "JavaScript:Void(0);",
"jumpForward_text" : 10,
"jumpForward_url" : "JavaScript:Void(0);",
"pagination__list" : [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],}
%}
<nav class="vf-pagination" aria-label="Pagination">
<ul class="vf-pagination__list">
<li class="vf-pagination__item vf-pagination__item--jump-back">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="First page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M13.5 5.5L8.5 10.5L13.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M9.5 5.5L4.5 10.5L9.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">First page</span>
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--previous-page">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="Previous page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M11.5 5.5L6.5 10.5L11.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">Previous page</span>
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>1
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>2
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>3
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--next-page">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="Next page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M8.5 5.5L13.5 10.5L8.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">Next page</span>
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--jump-forward">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="Last page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M6.5 5.5L11.5 10.5L6.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M10.5 5.5L15.5 10.5L10.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">Last page</span>
</a>
</li>
</ul>
</nav>
Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
includeYou'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"exampleMultiColumns" : "false",
"component-type" : "block",
"previous_text" : "Previous",
"previous_url" : "JavaScript:Void(0);",
"next_text" : "Next",
"next_url" : "JavaScript:Void(0);",
"jumpBack_text" : -10,
"jumpBack_url" : "JavaScript:Void(0);",
"jumpForward_text" : 10,
"jumpForward_url" : "JavaScript:Void(0);",
"pagination__list" : [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],
}
%}
{% include "../path_to/vf-pagination/vf-pagination.njk" %}
renderThis approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
{% render '@vf-pagination', {
"exampleMultiColumns" : "false",
"component-type" : "block",
"previous_text" : "Previous",
"previous_url" : "JavaScript:Void(0);",
"next_text" : "Next",
"next_url" : "JavaScript:Void(0);",
"jumpBack_text" : -10,
"jumpBack_url" : "JavaScript:Void(0);",
"jumpForward_text" : 10,
"jumpForward_url" : "JavaScript:Void(0);",
"pagination__list" : [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],}
%}
<nav class="vf-pagination" aria-label="Pagination">
<ul class="vf-pagination__list">
<li class="vf-pagination__item vf-pagination__item--previous-page">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="Previous page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M11.5 5.5L6.5 10.5L11.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">Previous page</span>
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>1
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>2
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>3
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--is-active">
<span class="vf-pagination__label" aria-current="page">
<span class="vf-u-sr-only">Page </span>4
</span>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>5
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>6
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>7
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--next-page">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="Next page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M8.5 5.5L13.5 10.5L8.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">Next page</span>
</a>
</li>
</ul>
</nav>
Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
includeYou'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"exampleMultiColumns" : "false",
"component-type" : "block",
"previous_text" : "Previous",
"previous_url" : "JavaScript:Void(0);",
"next_text" : "Next",
"next_url" : "JavaScript:Void(0);",
"jumpBack_text" : -10,
"jumpBack_url" : "JavaScript:Void(0);",
"jumpForward_text" : 10,
"jumpForward_url" : "JavaScript:Void(0);",
"pagination__list" : [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],
}
%}
{% include "../path_to/vf-pagination/vf-pagination.njk" %}
renderThis approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
{% render '@vf-pagination', {
"exampleMultiColumns" : "false",
"component-type" : "block",
"previous_text" : "Previous",
"previous_url" : "JavaScript:Void(0);",
"next_text" : "Next",
"next_url" : "JavaScript:Void(0);",
"jumpBack_text" : -10,
"jumpBack_url" : "JavaScript:Void(0);",
"jumpForward_text" : 10,
"jumpForward_url" : "JavaScript:Void(0);",
"pagination__list" : [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],}
%}
<nav class="vf-pagination" aria-label="Pagination">
<ul class="vf-pagination__list">
<li class="vf-pagination__item vf-pagination__item--previous-page">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="Previous page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M11.5 5.5L6.5 10.5L11.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">Previous page</span>
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>1
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>2
</a>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>3
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--is-active">
<span class="vf-pagination__label" aria-current="page">
<span class="vf-u-sr-only">Page </span>4
</span>
</li>
<li class="vf-pagination__item">
<a href="JavaScript:Void(0);" class="vf-pagination__link" onclick="window.scrollTo(0,100)">
<span class="vf-u-sr-only">Page </span>5
</a>
</li>
<li class="vf-pagination__item vf-pagination__item--next-page">
<a href="JavaScript:Void(0);" class="vf-pagination__link" aria-label="Next page">
<span class="vf-pagination__icon" aria-hidden="true" onclick="window.scrollTo(0,100)">
<svg width="16" height="16" viewBox="0 0 20 20" focusable="false" xmlns="http://www.w3.org/2000/svg">
<path d="M8.5 5.5L13.5 10.5L8.5 15.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<span class="vf-u-sr-only">Next page</span>
</a>
</li>
</ul>
</nav>
This repository is distributed with npm. After installing npm and yarn, you can install with this command.
$ yarn add --dev @visual-framework/vf-pagination
The style files included are written in Sass. If you're using a VF-core project, you can import it like this:
@import "@visual-framework/vf-pagination/index.scss";
Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter
set- style functions to cleaner version
File system location: components/vf-pagination
Find an issue on this page? Propose a change or discuss it.
Are you sure you want to close the chat?
Your current conversation history will be permanently deleted.