Pagination

Pagination provides basic previous, next, and page links without owning data or page state.

Overview and decision boundary

Use Pagination when the product already has page URLs and needs basic previous, next, and page navigation.

Do not add page calculation, data fetching, or table state management to Pagination.

Preview

import * as React from 'react';import { Pagination } from '@nerio-ui/ui';const AppLink = React.forwardRef<HTMLAnchorElement, React.AnchorHTMLAttributes<HTMLAnchorElement>>(function AppLink(props, ref) {  return <a ref={ref} data-router-link="" {...props} />;});<Pagination previousHref="/docs/page/1" nextHref="/docs/page/3" pages={[{ key: '1', label: '1', href: '/docs/page/1' }, { key: '2', label: '2', href: '/docs/page/2', current: true, render: <AppLink href="#" /> }, { key: '3', label: '3', href: '/docs/page/3' }]} />

Installation and imports

Install the editable registry source, or use the matching package entrypoint when the product keeps Nerio as a workspace dependency.

pnpm dlx nerio add paginationimport * as React from 'react';import { Pagination } from '@nerio-ui/ui';

Usage

import * as React from 'react';import { Pagination } from '@nerio-ui/ui';const AppLink = React.forwardRef<HTMLAnchorElement, React.AnchorHTMLAttributes<HTMLAnchorElement>>(function AppLink(props, ref) {  return <a ref={ref} data-router-link="" {...props} />;});<Pagination previousHref="/docs/page/1" nextHref="/docs/page/3" pages={[{ key: '1', label: '1', href: '/docs/page/1' }, { key: '2', label: '2', href: '/docs/page/2', current: true, render: <AppLink href="#" /> }, { key: '3', label: '3', href: '/docs/page/3' }]} />

Variants

VariantPurpose
DefaultLink-based pagination with no client state.

Anatomy

SlotPurpose
rootNav landmark with aria-label="Pagination" by default.
listList of page navigation controls.
itemItem slot exposed through data-slot="item".
previousPrevious-page link or non-focusable disabled text.
pagePage link with optional current state.
ellipsisEllipsis slot exposed through data-slot="ellipsis".
nextNext-page link or non-focusable disabled text.

States

StatePurpose
CurrentCurrent links, buttons, router elements, and static pages use aria-current="page" plus the same stronger visual treatment.
DisabledUnavailable previous or next controls are not focusable.
FocusLinks use the shared Nerio focus ring.

Motion

  • hover
  • focus

Accessibility

  • Renders a nav landmark with aria-label="Pagination" by default.
  • Marks the current page with aria-current="page".
  • Current pages keep the same data-current visual hook whether they render as links, buttons, router elements, disabled text, or static text.
  • Disabled controls render as non-focusable text with aria-disabled; onSelect takes precedence over href when both are supplied.
  • Page, previous, and next render elements support router adapters while preserving href, data-slot, current-page state, and accessible labels.
  • Visible labels carry state; color is not the only indicator.

API

PropPurpose
pagesArray of page labels, hrefs, current flags, optional disabled states, and optional router render elements.
previousHref / nextHrefWhen omitted, the control renders disabled and is not focusable.
previousLabel / nextLabelVisible labels for the boundary controls.
classNameExtends the nav root without replacing tokenized defaults.

Implementation contract

ContractValue
Registry itempagination installs 5 source files into the configured components directory.
Base UINo interactive primitive required.
Registry dependenciesNone.
Package dependenciesclsx, react, tailwind-merge, tailwindcss

Styling contract

ContractValue
AuthoringComplete, statically detectable Tailwind CSS v4 recipes own component visuals.
ValuesSemantic and component --n-* variables remain the canonical customization layer.
OverridesCustomizable slots merge consumer className values with tailwindCn so conflicting utilities resolve deterministically.
Residual CSSOnly shared keyframes and scoped no-Preflight compatibility rules remain; there is no parallel visual selector layer.

Design notes

  • Use Pagination when the product already has page URLs and needs basic previous, next, and page navigation.

Do / do not

Do

Use with server-rendered list pages, docs archives, and simple result sets.

Do not

Do not add page calculation, data fetching, or table state management to Pagination.

Tokens

These are the primary customization points. Override semantic or component tokens instead of changing component source.

TokenPurpose
--n-pagination-gapPublic customization point for this component contract.
--n-pagination-item-sizePublic customization point for this component contract.
--n-pagination-control-padding-inlinePublic customization point for this component contract.
--n-pagination-radiusPublic customization point for this component contract.
--n-pagination-backgroundPublic customization point for this component contract.
--n-pagination-background-hoverPublic customization point for this component contract.
--n-pagination-background-currentPublic customization point for this component contract.
--n-pagination-border-widthPublic customization point for this component contract.
--n-pagination-borderPublic customization point for this component contract.
--n-pagination-border-currentPublic customization point for this component contract.
--n-pagination-foregroundPublic customization point for this component contract.
--n-pagination-foreground-hoverPublic customization point for this component contract.
--n-pagination-foreground-currentPublic customization point for this component contract.
--n-pagination-shadowPublic customization point for this component contract.
--n-pagination-shadow-currentPublic customization point for this component contract.
--n-motion-hover-durationPublic customization point for this component contract.
--n-motion-hover-easingPublic customization point for this component contract.
--n-motion-focus-durationPublic customization point for this component contract.
--n-motion-focus-easingPublic customization point for this component contract.
--n-focus-ringPublic customization point for this component contract.