Pagination
A navigation landmark for moving between pages of results, composing a <nav> root, an <ul> list, and <li> items around two interactive parts.
Page 4 of 12 · 284 results
View code
let page = 4;
function goTo(next: number) {
page = Math.min(TOTAL, Math.max(1, next));
void handle.update();
}
<Pagination aria-label="Search results pages">
<Pagination.List>
<Pagination.Item>
<Pagination.Button
aria-label="Previous page"
disabled={page === 1}
mix={[on<HTMLButtonElement, "click">("click", () => goTo(page - 1))]}
>
<ChevronLeftIcon />
</Pagination.Button>
</Pagination.Item>
{pageWindow(page, TOTAL).map((item) =>
item.kind === "gap" ? (
<Pagination.Item key={"gap-" + item.after}>
<Pagination.Link aria-disabled="true">…</Pagination.Link>
</Pagination.Item>
) : (
<Pagination.Item key={item.page}>
<Pagination.Link
href={"?page=" + item.page}
aria-current={item.page === page ? "page" : undefined}
mix={[
on<HTMLAnchorElement, "click">("click", (event) => {
event.preventDefault();
goTo(item.page);
}),
]}
>
{item.page}
</Pagination.Link>
</Pagination.Item>
),
)}
<Pagination.Item>
<Pagination.Button
aria-label="Next page"
disabled={page === TOTAL}
mix={[on<HTMLButtonElement, "click">("click", () => goTo(page + 1))]}
>
<ChevronRightIcon />
</Pagination.Button>
</Pagination.Item>
</Pagination.List>
</Pagination>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/uiimport "@sdxc/ui/theme.css";Usage
import { Pagination } from "@sdxc/ui";Renders the pagination's <nav> root, laying its single Pagination.List child out as a centered row. In dev mode, a root missing
aria-label/aria-labelledby logs a console.warn for assistive tech.
Composition
The parts the component publishes, each a static property of the host.
PaginationPagination.ListRenders the pagination's<ul>list, resetting native list markers and spacing and laying Pagination.Item children out as a centered row with a small gap between them.Pagination.ItemRenders a single<li>wrapping one Pagination.Link or Pagination.Button, centering its content — this element carries no visual styling of its own beyond the layout needed to hold its child.Pagination.LinkRenders a page-number destination as a native<a>.Pagination.ButtonRenders a previous/next control as a native<button>.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
Also accepts everything in TagProps<"nav">.
Pagination.List
Also accepts everything in TagProps<"ul">.
Pagination.Item
Also accepts everything in TagProps<"li">.
Pagination.Link
Pagination.Button
Also accepts everything in TagProps<"button">.