Bootstrap

Bootstrap Pagination

Simplifying Navigation with Bootstrap Pagination

When your website or app has lots of content spread across multiple pages—like blog posts, products, or search results—pagination helps users navigate efficiently. Bootstrap’s built-in Pagination component provides a clean, responsive, and customizable way to add page navigation to your project.

What Is Bootstrap Pagination?

Bootstrap Pagination is a set of styled page links that guide users through different pages of content. It supports simple numbered pages, previous/next buttons, and even disabled or active states, ensuring clarity and usability.

Basic Pagination Example

Here’s how you create a simple pagination bar:

html
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active" aria-current="page">
<a class="page-link" href="#">2</a>
</li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
</nav>
  • .pagination creates the pagination container.

  • .page-item wraps each page number or control.

  • .page-link styles the actual clickable link.

  • .active highlights the current page.

  • You can disable links using .disabled.

Disabled and Active States

Disable a page item (for example, the “Previous” button on the first page) by adding .disabled:

html
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
</li>

Sizing Pagination

You can adjust the size of pagination components with:

  • .pagination-lg for large pagination

  • .pagination-sm for small pagination

Example:

html
<ul class="pagination pagination-sm">
<!-- page items -->
</ul>

Alignment

Pagination can be aligned using Bootstrap’s flex utilities:

  • Left (default)

  • Center: add .justify-content-center to .pagination

  • Right: add .justify-content-end to .pagination

Example:

html
<ul class="pagination justify-content-center">
<!-- page items -->
</ul>

Why Use Bootstrap Pagination?

  • Improves user navigation on multi-page content

  • Responsive and mobile-friendly by default

  • Accessible with ARIA roles and attributes

  • Easy to customize and integrate with your backend logic

Leave a Reply

Your email address will not be published. Required fields are marked *