Skip to content

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.

Also known as: table pagination with page size, rows per page selector, paginated data table footer, pagination with ellipsis, dark table pagination

Bootstrap 5 Pagination Responsive Dark #dark #pagination #responsive #select #table

Pagination with Items Per Page Selector live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A dark Bootstrap 5 data table footer that combines a rows-per-page select, a "Showing 1–5 of 47" range text and a windowed pagination bar with ellipsis. Use it under order lists, admin tables, search results or any long list that needs client-side paging.

How it works

The root section.pp-wrap sets data-bs-theme="dark", so Bootstrap's own form and table styles switch to their dark color mode. Inside, .pp-panel holds a header, a table.pp-table wrapped in table-responsive, and the .pp-foot bar. The footer contains the select.pp-size with its label, the .pp-range text and an empty ul.pagination.pp-pages.

On DOMContentLoaded the script initializes every .pp-wrap. It builds sample orders from the count in data-pp-total, then renders the current slice into tbody.pp-rows and rebuilds the pager. The pageList() helper always shows the first and last page, the current page and one neighbor on each side, and collapses everything else into an ellipsis, so the bar stays short even with many pages. Previous and next buttons are disabled on the first and last page.

A click listener on the pager reads data-page from the clicked button and calls go(). A change listener on the select recalculates the page so the first visible row stays in view: if you are looking at rows 11–15 and switch to 10 per page, you land on page 2 with rows 11–20. Each status is shown with a .pp-badge--paid, .pp-badge--pending or .pp-badge--refunded pill.

Customization

  • data-pp-total on .pp-panel: the number of sample rows. Replace buildOrders() in script.js with data from your API or a fetch() call.
  • <option> values in select.pp-size: offer other page sizes; mark a different one selected to change the default.
  • Math.abs(p - current) <= 1 in pageList(): use <= 2 to show two neighbors on each side of the current page.
  • --pp-accent in .pp-wrap: changes the active page button and the focus border of the select; pair it with --pp-accent-ink for the active page number color.
  • --pp-bg, --pp-panel and --pp-line: set the page background, panel color and divider lines.
  • max-width: 920px in .pp-panel: make the table wider or narrower.
  • currency: 'USD' in the Intl.NumberFormat call: format amounts in another currency.

Use cases

  • Admin dashboards: lets staff choose how many orders show per page and jump through long tables
  • Order and invoice lists: shows a Showing 1–5 of 47 range with paid, pending and refunded status pills
  • Search results pages: pages through long result lists with a windowed pager that stays short
  • Internal tools: keeps the first visible row in view when the page size changes

Accessibility

The pagination sits in a nav labelled "Orders pages". Every page button has an aria-label such as "Page 3", the active one has aria-current="page", and the chevron buttons are labelled "Previous page" and "Next page" with their icons hidden from screen readers. Ellipsis items are aria-hidden. After a click, focus moves to the matching button in the re-rendered list, so keyboard users do not lose their place. The .pp-range text is a polite live region that announces the new range. The select has a visible label, and the table has a visually hidden caption.

Usage notes

Requires Bootstrap 5.3 for data-bs-theme (added automatically) and Bootstrap Icons for the chevrons. Each .pp-wrap keeps its own state, so several tables can share a page. Without JavaScript the table shows a loading row.

Pagination with Items Per Page Selector 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, dark design
Category
Pagination
License
Free for personal and commercial use

Questions about this template

Can I use the Pagination with Items Per Page Selector 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 Items Per Page Selector – free Bootstrap 5 pagination template
Pagination with Items Per Page Selector · free Bootstrap 5 pagination template

More Pagination

Pagination with Page Jump – free Bootstrap 5 pagination template

Pagination with Page Jump

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

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 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.