Overview

We use a large block of connected links for our pagination, making links hard to miss and easily scalable—all while providing large hit areas. Pagination is built with list HTML elements so screen readers can announce the number of available links. Use a wrapping <nav> element to identify it as a navigation section to screen readers and other assistive technologies.

In addition, as pages likely have more than one such navigation section, it’s advisable to provide a descriptive aria-label for the <nav> to reflect its purpose. For example, if the pagination component is used to navigate between a set of search results, an appropriate label could be aria-label="Search results pages".

Pagination - 图1

  1. <nav aria-label="Page navigation example">
  2. <ul class="pagination">
  3. <li class="page-item"><a class="page-link" href="#">Previous</a></li>
  4. <li class="page-item"><a class="page-link" href="#">1</a></li>
  5. <li class="page-item"><a class="page-link" href="#">2</a></li>
  6. <li class="page-item"><a class="page-link" href="#">3</a></li>
  7. <li class="page-item"><a class="page-link" href="#">Next</a></li>
  8. </ul>
  9. </nav>

Working with icons

Looking to use an icon or symbol in place of text for some pagination links? Be sure to provide proper screen reader support with aria attributes.

Pagination - 图2

  1. <nav aria-label="Page navigation example">
  2. <ul class="pagination">
  3. <li class="page-item">
  4. <a class="page-link" href="#" aria-label="Previous">
  5. <span aria-hidden="true">&laquo;</span>
  6. </a>
  7. </li>
  8. <li class="page-item"><a class="page-link" href="#">1</a></li>
  9. <li class="page-item"><a class="page-link" href="#">2</a></li>
  10. <li class="page-item"><a class="page-link" href="#">3</a></li>
  11. <li class="page-item">
  12. <a class="page-link" href="#" aria-label="Next">
  13. <span aria-hidden="true">&raquo;</span>
  14. </a>
  15. </li>
  16. </ul>
  17. </nav>

Disabled and active states

Pagination links are customizable for different circumstances. Use .disabled for links that appear un-clickable and .active to indicate the current page.

While the .disabled class uses pointer-events: none to try to disable the link functionality of <a>s, that CSS property is not yet standardized and doesn’t account for keyboard navigation. As such, you should always add tabindex="-1" on disabled links and use custom JavaScript to fully disable their functionality.

Pagination - 图3

  1. <nav aria-label="...">
  2. <ul class="pagination">
  3. <li class="page-item disabled">
  4. <a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
  5. </li>
  6. <li class="page-item"><a class="page-link" href="#">1</a></li>
  7. <li class="page-item active" aria-current="page">
  8. <a class="page-link" href="#">2</a>
  9. </li>
  10. <li class="page-item"><a class="page-link" href="#">3</a></li>
  11. <li class="page-item">
  12. <a class="page-link" href="#">Next</a>
  13. </li>
  14. </ul>
  15. </nav>

You can optionally swap out active or disabled anchors for <span>, or omit the anchor in the case of the prev/next arrows, to remove click functionality and prevent keyboard focus while retaining intended styles.

Pagination - 图4

  1. <nav aria-label="...">
  2. <ul class="pagination">
  3. <li class="page-item disabled">
  4. <span class="page-link">Previous</span>
  5. </li>
  6. <li class="page-item"><a class="page-link" href="#">1</a></li>
  7. <li class="page-item active" aria-current="page">
  8. <span class="page-link">2</span>
  9. </li>
  10. <li class="page-item"><a class="page-link" href="#">3</a></li>
  11. <li class="page-item">
  12. <a class="page-link" href="#">Next</a>
  13. </li>
  14. </ul>
  15. </nav>

Sizing

Fancy larger or smaller pagination? Add .pagination-lg or .pagination-sm for additional sizes.

Pagination - 图5

  1. <nav aria-label="...">
  2. <ul class="pagination pagination-lg">
  3. <li class="page-item active" aria-current="page">
  4. <span class="page-link">1</span>
  5. </li>
  6. <li class="page-item"><a class="page-link" href="#">2</a></li>
  7. <li class="page-item"><a class="page-link" href="#">3</a></li>
  8. </ul>
  9. </nav>

Pagination - 图6

  1. <nav aria-label="...">
  2. <ul class="pagination pagination-sm">
  3. <li class="page-item active" aria-current="page">
  4. <span class="page-link">1</span>
  5. </li>
  6. <li class="page-item"><a class="page-link" href="#">2</a></li>
  7. <li class="page-item"><a class="page-link" href="#">3</a></li>
  8. </ul>
  9. </nav>

Alignment

Change the alignment of pagination components with flexbox utilities.

Pagination - 图7

  1. <nav aria-label="Page navigation example">
  2. <ul class="pagination justify-content-center">
  3. <li class="page-item disabled">
  4. <a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
  5. </li>
  6. <li class="page-item"><a class="page-link" href="#">1</a></li>
  7. <li class="page-item"><a class="page-link" href="#">2</a></li>
  8. <li class="page-item"><a class="page-link" href="#">3</a></li>
  9. <li class="page-item">
  10. <a class="page-link" href="#">Next</a>
  11. </li>
  12. </ul>
  13. </nav>

Pagination - 图8

  1. <nav aria-label="Page navigation example">
  2. <ul class="pagination justify-content-end">
  3. <li class="page-item disabled">
  4. <a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
  5. </li>
  6. <li class="page-item"><a class="page-link" href="#">1</a></li>
  7. <li class="page-item"><a class="page-link" href="#">2</a></li>
  8. <li class="page-item"><a class="page-link" href="#">3</a></li>
  9. <li class="page-item">
  10. <a class="page-link" href="#">Next</a>
  11. </li>
  12. </ul>
  13. </nav>