Pagination in React
Complete pagination with the current page, ellipses and previous/next arrows that are properly disabled.
Here is an excerpt of this component's code in React. The full code is free for members, ready to copy into your project.
This component also comes in
The code in React
const visuallyHiddenOnPhones =
"max-[29.99rem]:absolute max-[29.99rem]:size-px max-[29.99rem]:overflow-hidden max-[29.99rem]:[clip-path:inset(50%)] max-[29.99rem]:whitespace-nowrap";
/** Page numbers to show, with null where an ellipsis replaces skipped pages. */
export function pageItems(current: number, total: number): (number | null)[] {
const keep = new Set([1, total, current - 1, current, current + 1]);
if (current <= 3) [2, 3, 4].forEach((page) => keep.add(page));
if (current >= total - 2) [total - 1, total - 2, total - 3].forEach((page) => keep.add(page));
const pages = [...keep].filter((page) => page >= 1 && page <= total).sort((a, b) => a - b);
const items: (number | null)[] = [];
pages.forEach((page, index) => {
if (index > 0 && page - pages[index - 1] > 1) items.push(null);Free component: copy it freely, including for commercial projects.
Other breadcrumbs and pagination components in React
Breadcrumbs and pagination components in React
A bottom bar with Call, Directions and Free quote that tucks away while visitors read down the page and returns as soon as they scroll up. Built for tradespeople whose customers arrive on a phone.
- Tailwind
- React
- CSS
- WordPress

A slim bar at the top of the page with a message, a link and a close button; once closed, it stays hidden for the period you choose.
- Tailwind
- React
- CSS
- WordPress

A sticky sidebar table of contents for blog posts: it highlights the section being read, shows the reading time left and folds into a list under the title on mobile.
- Tailwind
- React
- CSS
- WordPress

A column of dots on the side of the page that follows the section being read and lets visitors jump to it, with a label on hover and focus.
- Tailwind
- React
- CSS
- WordPress

Step indicator
FreeAn order step indicator: finished steps clickable to go back, the current step announced, upcoming steps locked.
- Tailwind
- React
- CSS
- WordPress

Tooltips in four positions that open on hover, tap and keyboard focus, and close with Escape, as WCAG requires.
- Tailwind
- React
- CSS
- WordPress