Navigation
Pagination
Free14.3 KB gzippedPage navigation: a <nav> landmark with a list of pill page buttons, Previous/Next arrows, optional First/Last, and gaps for long ranges. The current page has aria-current="page". Pass getHref to render links for server-routed pages, or compact for a small-screen "Page 3 of 12" layout.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab · Full report
Import
import { Pagination } from "@vjdesigns/vjdesigns-ui";
Importing only Pagination adds about 14.3 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
Ellipses keep the control short; siblingCount and boundaryCount decide how many numbers show.
Showing results 41–50
import { useState } from "react";
import { Pagination, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function Basic() {
const [page, setPage] = useState(5);
return (
<Stack gap={3} align="center">
<Pagination pageCount={12} page={page} onPageChange={setPage} />
<Text size="sm" tone="muted">
Showing results {page * 10 - 9}–{page * 10}
</Text>
</Stack>
);
}
Variants
import { Pagination, Stack } from "@vjdesigns/vjdesigns-ui";
export function Variants() {
return (
<Stack gap={4} align="center">
<Pagination pageCount={20} defaultPage={10} variant="outline" showFirstLast />
<Pagination pageCount={20} defaultPage={10} variant="soft" size="sm" />
</Stack>
);
}
Compact
compact replaces the numbers with "Page 3 of 12", for small screens.
import { Pagination } from "@vjdesigns/vjdesigns-ui";
export function Compact() {
return <Pagination pageCount={12} defaultPage={3} compact />;
}
Accessibility
Pagination is a navigation landmark. Each button has a full name ("Go to page 5", "Next page"), and the current page is marked aria-current="page". Show the effect of a page change in text too, as here.
Showing orders 41–60 of 200
import { useState } from "react";
import { Pagination, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
const [page, setPage] = useState(3);
return (
<Stack gap={3} align="center">
<Pagination pageCount={10} page={page} onPageChange={setPage} showFirstLast />
<Text size="sm" tone="muted" role="status">
Showing orders {page * 20 - 19}–{page * 20} of 200
</Text>
</Stack>
);
}
Translated
In Arabic the pages run right to left, the previous and next arrows point the other way, and every button's name comes from the locale.
import { Pagination, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
export function Translated() {
return (
<LocaleProvider locale="ar" messages={ar}>
<Pagination pageCount={12} defaultPage={4} />
</LocaleProvider>
);
}
API reference
Pagination
| Prop | Type | Default |
|---|---|---|
pageCountRequiredTotal number of pages. With a total item count, pass | number | — |
pageCurrent page (1-based) when controlled. | number | — |
defaultPageInitial page (1-based) when uncontrolled. | number | 1 |
onPageChangeCalled with the new page (1-based) when the user picks a page. | (page: number) => void | — |
siblingCountPages shown on each side of the current page. | number | 1 |
boundaryCountPages always shown at the start and end. | number | 1 |
showFirstLastAdds First and Last page buttons outside Previous and Next. | boolean | false |
compactCompact mode for small screens: Previous and Next around a "Page 3 of 12" status (announced politely when it changes). | boolean | false |
sizeControl size. | "sm""md""lg" | "md" |
variantLook of the non-current page buttons and the arrows. The current page is always a solid primary pill. | "ghost""outline""soft" | "ghost" |
disabledDisables every control. | boolean | false |
getHrefRenders every control as a link ( | (page: number) => string | — |
onLinkClickLink mode only: runs on a plain (unmodified) click of a page link. Call | (page: number, event: MouseEvent<HTMLElement>) => void | — |
getItemAriaLabelAccessible name for each control, for localization. Defaults to "Previous page", "Next page", "First page", "Last page", "Go to page 5", and "Page 5" for the current page. Keep the visible page number in the name. | (type: PaginationItemType, page: number, current: boolean) => string | — |
formatStatusStatus text in compact mode. | (page: number, pageCount: number) => ReactNode | (page, count) => "Page 3 of 12" |
Also accepts native <nav> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Pagination targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Tab | Moves through the page buttons; Enter or Space goes to that page. |
Roles and states
| Element | Role | States and properties |
|---|---|---|
<nav> | navigation | aria-label ("Pagination") |
| Page button | button | aria-label ("Page 3"), aria-current="page" on the current one |
| Live region | none | aria-live="polite": announces the new page |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |