Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Navigation

Pagination

Free14.3 KB gzipped

Page 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

tsx
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

tsx
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

tsx
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.

tsx
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

tsx
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.

tsx
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

Pagination props
PropTypeDefault
pageCountRequired

Total number of pages. With a total item count, pass Math.ceil(total / pageSize). 0 renders the Previous/Next controls, disabled.

number—
page

Current page (1-based) when controlled.

number—
defaultPage

Initial page (1-based) when uncontrolled.

number1
onPageChange

Called with the new page (1-based) when the user picks a page.

(page: number) => void—
siblingCount

Pages shown on each side of the current page.

number1
boundaryCount

Pages always shown at the start and end.

number1
showFirstLast

Adds First and Last page buttons outside Previous and Next.

booleanfalse
compact

Compact mode for small screens: Previous and Next around a "Page 3 of 12" status (announced politely when it changes).

booleanfalse
size

Control size.

"sm""md""lg""md"
variant

Look of the non-current page buttons and the arrows. The current page is always a solid primary pill.

"ghost""outline""soft""ghost"
disabled

Disables every control.

booleanfalse
getHref

Renders every control as a link (<a href>) instead of a button, for server-routed pagination. Return the URL for a page, e.g. (page) => "?page=" + page. Only called for enabled controls with a page in range; disabled ends render without href. A plain click follows the link (no state change or onPageChange before the page unloads); for a client-side router, see onLinkClick.

(page: number) => string—
onLinkClick

Link mode only: runs on a plain (unmodified) click of a page link. Call event.preventDefault() and navigate with your router; the page state then updates and onPageChange fires as for buttons.

(page: number, event: MouseEvent<HTMLElement>) => void—
getItemAriaLabel

Accessible 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—
formatStatus

Status 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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 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

Keyboard
KeyAction
TabMoves through the page buttons; Enter or Space goes to that page.

Roles and states

Roles and states
ElementRoleStates and properties
<nav>navigationaria-label ("Pagination")
Page buttonbuttonaria-label ("Page 3"), aria-current="page" on the current one
Live regionnonearia-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.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)