Skip to content

Pagination with Page Jump

Bootstrap 5 pagination with smart ellipses, previous and next arrows, a page counter and a validated 'go to page' input.

Also known as: page number navigation, pagination with ellipsis, go to page input, paginated results bar

Pagination with Page Jump live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A Bootstrap 5 pagination bar with smart ellipses, previous and next arrows, a "Page 7 of 42" counter and a "Go to page" field for jumping straight to any page. It suits search results, data tables, archives and admin lists with many pages.

How it works

The root .pgj stores its state in data attributes: data-pgj-total, data-pgj-current and data-pgj-siblings. It holds three parts: the .pgj-info counter, a nav with Bootstrap's ul.pagination.pgj-pages, and the form.pgj-jump with a number input and a Go button. The markup ships pre-rendered for page 7, so it looks complete before the script runs.

On DOMContentLoaded the script reads the attributes and rebuilds the list with render(). The helper buildPages() always keeps the first and last page, shows data-pgj-siblings pages on each side of the current one and inserts a .pgj-gap item where pages are skipped. Previous and next become disabled span elements on the first and last page. Clicks on any a[data-page] are handled by one delegated listener that calls goTo(), re-renders the list, moves focus back to the same arrow or to the new current page, updates data-pgj-current and fires a bubbling pgj:change event with detail.page and detail.total.

The jump form checks that the value is a whole number between 1 and the total. Invalid input gets is-invalid, aria-invalid="true" and shows .pgj-error; typing again clears the error.

Customization

  • data-pgj-total and data-pgj-current on .pgj: set the number of pages and the starting page; the input max, placeholder and error text update automatically.
  • data-pgj-siblings on .pgj: use 2 to show two pages on each side of the current page, or 0 for a compact bar.
  • --pgj-accent in style.css: recolors the active page, Go button and focus rings.
  • --pgj-size: changes the width and height of each page button (it shrinks to 2.1rem on phones).
  • --pgj-radius: use 50% for round page buttons or 0.25rem for sharper ones.
  • Listen for pgj:change on .pgj, or edit goTo() in script.js, to fetch() the rows for the new page.

Use cases

  • Search results pages: previous and next arrows and smart ellipses keep long result lists easy to browse
  • Data tables and admin lists: a Go to page field lets users jump straight to any page
  • Blog archives: a Page 7 of 42 counter tells readers how far along they are
  • Dynamic listings: a page change event lets you fetch the rows for the newly selected page

Accessibility

The list sits in a nav labelled "Results pages", and the current page has aria-current="page". Arrow links have aria-label values "Previous page" and "Next page", disabled arrows use aria-disabled, and ellipsis items are aria-hidden. The counter is a role="status" live region, so page changes are announced. The field has a visible label, aria-describedby points to the error message and aria-invalid reflects its state. Focus is kept inside the pagination after each change, and every control has a visible focus ring.

Usage notes

Requires Bootstrap 5 (added automatically) and Bootstrap Icons. For several instances on one page, give each input a unique id and update the for and aria-describedby values.

Pagination with Page Jump at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Pagination
License
Free for personal and commercial use

Questions about this template

Can I use the Pagination with Page Jump code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Pagination with Page Jump – free Bootstrap 5 pagination template
Pagination with Page Jump · free Bootstrap 5 pagination template

More Pagination

Rounded Pagination – free Pure CSS pagination template

Rounded Pagination

Pill-shaped pagination with ellipsis, previous/next buttons and a gradient active page, made interactive with a few lines of vanilla JS.

Pagination with Items Per Page Selector – free Bootstrap 5 pagination template

Pagination with Items Per Page Selector

Dark Bootstrap 5 orders table with a rows-per-page select, live range text and windowed pagination with ellipsis and prev/next buttons.

Pagination with Results Info – free Tailwind CSS pagination template

Pagination with Results Info

Tailwind CSS pagination bar with Previous/Next, numbered pages with ellipsis, a per-page select and a live 'Showing 1 to 10 of 97 results' summary.