Pagination
Pagination is a type of navigation that lets users click through pages of search results, products, or other related items.
Basics
A pagination list is just a <ul>
with the class .pagination
, and a series of <li>
/<a>
pairs. Add the class .current
to an <li>
to mark the current page, or .disabled
to add disabled styles to a link.
Note that the list is nested inside a <nav>
with the attributes aria-label="Pagination"
. This explains the purpose of the component to assistive technologies.
Extra screen reader-only text should also be added to a pagination element. In the below example, users reading the page will just see "Next" and "Previous", but screen readers will read it as "Next page" and "Previous page". Additionally, the text for the current page will read as "You're on page one".
<nav aria-label="Pagination">
<ul class="pagination">
<li class="pagination-previous disabled">Previous <span class="show-for-sr">page</span></li>
<li class="current"><span class="show-for-sr">You're on page</span> 1</li>
<li><a href="#" aria-label="Page 2">2</a></li>
<li><a href="#" aria-label="Page 3">3</a></li>
<li><a href="#" aria-label="Page 4">4</a></li>
<li class="ellipsis" aria-hidden="true"></li>
<li><a href="#" aria-label="Page 12">12</a></li>
<li><a href="#" aria-label="Page 13">13</a></li>
<li class="pagination-next"><a href="#" aria-label="Next page">Next <span class="show-for-sr">page</span></a></li>
</ul>
</nav>
Centered
The items in a pagination list are display: inline-block
, which makes centering them easy. Use our built-in .text-center
class, or add text-align: center
in your CSS.
<nav aria-label="Pagination">
<ul class="pagination text-center">
<li class="pagination-previous disabled">Previous</li>
<li class="current"><span class="show-for-sr">You're on page</span> 1</li>
<li><a href="#" aria-label="Page 2">2</a></li>
<li><a href="#" aria-label="Page 3">3</a></li>
<li><a href="#" aria-label="Page 4">4</a></li>
<li class="ellipsis"></li>
<li><a href="#" aria-label="Page 12">12</a></li>
<li><a href="#" aria-label="Page 13">13</a></li>
<li class="pagination-next"><a href="#" aria-label="Next page">Next</a></li>
</ul>
</nav>
Sass Reference
Variables
The default styles of this component can be customized using these Sass variables in your project's settings file.
Mixins
We use these mixins to build the final CSS output of this component. You can use the mixins yourself to build your own class structure out of our components.
pagination-container
@include pagination-container;
Adds styles for a pagination container. Apply this to a <ul>
.
pagination-item-current
@include pagination-item-current;
Adds styles for the current pagination item. Apply this to an <a>
.
pagination-item-disabled
@include pagination-item-disabled;
Adds styles for a disabled pagination item. Apply this to an <a>
.
pagination-ellipsis
@include pagination-ellipsis;
Adds styles for an ellipsis for use in a pagination list.