Pagination
Clean pagination with prev/next and page numbers.
<nav aria-label="Pagination" class="flex items-center gap-1.5">
<a href="#" aria-label="Previous page" class="w-10 h-10 rounded-xl border border-slate-200 flex items-center justify-center text-slate-500 dark:text-slate-400 hover:border-indigo-300 hover:text-indigo-600 transition-colors">
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7"/></svg>
</a>
<a href="#" class="w-10 h-10 rounded-xl bg-indigo-600 text-white text-sm font-bold flex items-center justify-center">1</a>
<a href="#" class="w-10 h-10 rounded-xl border border-slate-200 text-sm font-bold text-slate-600 dark:text-slate-300 flex items-center justify-center hover:border-indigo-300 hover:text-indigo-600 transition-colors">2</a>
<a href="#" class="w-10 h-10 rounded-xl border border-slate-200 text-sm font-bold text-slate-600 dark:text-slate-300 flex items-center justify-center hover:border-indigo-300 hover:text-indigo-600 transition-colors">3</a>
<span class="px-1 text-slate-400">...</span>
<a href="#" class="w-10 h-10 rounded-xl border border-slate-200 text-sm font-bold text-slate-600 dark:text-slate-300 flex items-center justify-center hover:border-indigo-300 hover:text-indigo-600 transition-colors">12</a>
<a href="#" aria-label="Next page" class="w-10 h-10 rounded-xl border border-slate-200 flex items-center justify-center text-slate-500 dark:text-slate-400 hover:border-indigo-300 hover:text-indigo-600 transition-colors">
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"/></svg>
</a>
</nav>Free to use in personal and commercial projects. No attribution required.
Variants
Same component, different looks. Preview each one live and copy the code you like.
Dark
Dark pagination belongs in dark footers and admin tables.
Rounded
Fully round buttons soften pagination on friendly consumer sites.
Simple
Text-only pagination keeps mobile layouts clean.
About this pagination
Pagination breaks long lists into digestible pages. This tailwind pagination follows the standard pattern: prev/next arrows, numbered buttons with the current page highlighted, and an ellipsis skipping to the last page. It is the pattern from search results to blog archives.
The current page gets the solid indigo fill; others are bordered buttons. The ellipsis prevents a dozen page buttons when you have many pages. Prev/next arrows have aria-labels for screen readers.
For fewer than 20 items, consider showing all. For infinite feeds, load-more buttons beat pagination. Pagination suits archives and search where users may want to jump to a specific page or share a page URL.
Long lists need chunking, and chunks need addresses. Page 4 of a blog archive must be shareable, bookmarkable, and returnable; infinite scroll can't do any of that. Pagination gives every slice of a list its own URL, which is why archives, search results, and galleries use it: sometimes the user needs to go back to exactly where they were.
The nav carries aria-label=Pagination with flex items-center gap-1.5. Prev and next are w-10 h-10 rounded-xl bordered buttons with chevron SVGs and aria-labels. Page numbers share the same footprint; the current page gets bg-indigo-600 text-white while the rest are bordered with hover states. An ellipsis collapses the middle when the count grows, so fifty pages never become fifty buttons.
Show at most five page numbers with ellipses beyond. Disable (don't hide) prev on page one and next on the last page, so the control's shape stays stable. Use real anchor links with ?page=N hrefs: crawlers follow them, users can open them in new tabs, and the back button works. Buttons with JS handlers break all three.
The boundary mistake is leaving prev clickable on page one, sending users to a page zero that 404s or duplicates content. It looks like a small oversight and reads as a broken site. Apply aria-disabled with dimmed styling at both ends; the control should communicate its limits, not just its options.
Frequently asked questions
Pagination vs infinite scroll?
Pagination for archives and search (jumpable, shareable URLs, SEO-friendly). Infinite scroll for feeds (engagement). Load-more buttons are a good middle ground.
How many page numbers should I show?
Five around the current page, plus first/last with ellipses. More buttons create clutter without helping navigation.
Should pagination use links or buttons?
Links (<a>) with real URLs for SEO and shareability. Buttons only if pagination is purely client-side with no URL change.
How do I add ellipsis to pagination?
Always show the first page, the last page, and the current page plus one neighbor on each side, replacing the gaps with an ellipsis character. This keeps the control a stable width whether there are 5 pages or 500. Mark the ellipsis aria-hidden since it is decorative.
How do I style the current page in pagination?
Give the current page a filled background in your brand color with white text, and add aria-current="page" so screen readers announce it. Render it as a span rather than a link since it goes nowhere. Ensure the contrast ratio passes against the page background.
Should pagination have previous and next buttons?
Yes, always include Previous and Next controls flanking the numbers for sequential navigation. Disable Previous on page 1 and Next on the last page with aria-disabled, and label them with aria-labels. On mobile you can collapse to just these two plus a "Page 3 of 12" readout.
Where to use it
- ✓ Blog archives
- ✓ Search results
- ✓ Product listings
- ✓ Table data
Design notes
When to use
Pagination fits large result sets where users may want to jump to a specific page or share a link to one, like blog archives or a gallery. The numbered buttons plus previous and next controls cover both precise jumps and casual browsing. Keeping the current page visibly distinct, as the bordered active box does here, prevents the am I on page 3 or 4 confusion.
What to avoid
Do not use pagination for feeds users scroll continuously, infinite scroll matches that behavior better. Avoid showing all fifty page numbers, collapse the middle with an ellipsis once the count grows. And do not reset the user to page one after every filter change without saying so, losing their place feels like a bug.
Accessibility
The nav landmark and aria-labels on the arrow buttons are the right pattern, keep them. Mark the current page with aria-current so screen readers announce it, and make sure focus moves sensibly when the page changes.
Customization tips
Show 5 page numbers max with ellipses beyond. Disable prev on page 1 and next on the last page. For SEO, use real links (not buttons) so crawlers follow pagination.