Navigation · astro-ui · Pagination

Pagination

Zero-JS linked page navigation with truncation ellipsis.

Pagination renders fully server-rendered page links — every page is a real <a>, so it works without JS and is crawlable. Pages outside the sibling window collapse into ellipsis; prev/next disable at the ends.

Features

  • Real links — crawlable, zero JS
  • Ellipsis truncation with siblingCount control
  • prev/next with end-disabling
  • compact arrows-only mode
  • 2 variants, 3 sizes

Usage

---
import { Pagination } from "astro-ui";
---

<Pagination
  page={2}
  total={9}
  pageHref={(p) => `/blog?page=${p}`}
/>

Demos

Basic

<Pagination
  page={4}
  total={12}
  pageHref={(p) => `?page=${p}`}
/>

Compact

<Pagination compact page={2} total={5} pageHref={(p) => `?p=${p}`} />

API

Props

PropTypeDefaultDescription
pagenumberrequired1-based current page.
totalnumberrequiredTotal pages.
pageHref(page: number) => stringrequiredURL builder per page.
siblingCountnumber1Pages shown each side before truncation.
showPrevNextbooleantruePrev/next controls.
compactbooleanfalseArrows-only mode.
variant"outline" | "ghost""outline"Control style.
size"sm" | "md" | "lg""md"Scale.
classstring—Merged via cn(); Tailwind classes welcome.
idstring—Element id.

Accessibility

Implemented accessibility features — semantics, ARIA wiring, and keyboard behavior that ship with the component.

  • Wrapped in <nav aria-label> as a navigable landmark
  • Real <a> links — crawlable and keyboard-operable without JS
  • aria-current="page" announces the current page; page arrows are labeled buttons with aria-hidden glyphs

FAQ

Why links instead of buttons?

Pagination navigates — real anchors keep it functional without JS, shareable, and indexable. SPA-style paging can layer on top app-side.

Changelog

Version history mentioning Pagination.

v0.1.0 — 2026-11-11
added
  • Navigation (7): Tabs, Breadcrumb, Pagination, Stepper, Tree, Navbar, Sidebar.