Skip to content
Nana UI

Navigation

Pagination

A navigation control for paged data. It lives beside a table or list, never inside it. Controlled-by-attribute but self-updating: clicking moves the page (updating page) and emits nana-page-change so consumers can slice (client-side) or refetch (server-side).

View .md Download

Pagination ships for all three targets. The React and Svelte versions are a focused subset of the web component’s API — page numbers, layouts and sizes, without the page-size and jump controls. Pick the tab for your project — the CLI detects which you are on and serves the matching implementation.

npx @nana-tec/ui add pagination

Lands as src/components/ui/pagination/pagination.tsx, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

import { Pagination } from "@/components/ui/pagination";
export function Example() {
const [page, setPage] = useState(1);
return (
<Pagination
page={page}
totalPages={12}
onPageChange={setPage}
/>
);
}

It is fully controlled: it renders page and reports the next one, and never holds state of its own. layout="compact" swaps the numbers for a “Page 3 of 12” readout; layout="simple" leaves only Previous and Next.

siblingCount and boundaryCount control how much of a long range stays visible before it collapses to an ellipsis — with the defaults, page 6 of 20 renders 1 … 5 6 7 … 20.

Classes you pass to the React and Svelte components are merged with tailwind-merge, so an override wins rather than fighting. See Using Tailwind.

The layout attribute switches between numbered (default), compact, and simple.

The React and Svelte props, read from the components’ own types:

Pagination

PropTypeDefault
pagerequirednumber
totalPagesrequirednumber
layoutPaginationLayout'numbered'
sizePaginationSize'md'
siblingCountnumber1
boundaryCountnumber1
disabledbooleanfalse
labelstring'Pagination'
onPageChange(page: number) => void

Also accepts Omit<HTMLAttributes<HTMLElement>, 'onChange'>.

The attribute names, events and CSS hooks below are the Web Components reference.

Properties

PropertyAttributeTypeDefaultDescription
boundaryCountboundary-countnumber1Page numbers pinned at each end
disableddisabledbooleanfalseDisable the whole control (e.g. while loading)
layoutlayoutPaginationLayout'numbered'Structural layout
pagepagenumber1Current page (1-based)
pageSizepage-sizenumber10Rows per page
pageSizeOptionspage-size-optionsstring'10,25,50,100'Comma-separated page-size options
showFirstLastshow-first-lastbooleanfalseShow « First / Last » buttons
showJumpshow-jumpbooleanfalseShow the jump-to-page input
showPageSizeshow-page-sizebooleanfalseShow the rows-per-page selector
showResultCountshow-result-countbooleanfalseShow the "Showing X–Y of Z" summary
siblingCountsibling-countnumber1Page numbers shown either side of the current page
sizesizePaginationSize'md'Control size
totalItemstotal-itemsnumber | undefined—Total number of items — derives total pages and the result count
totalPagestotal-pagesnumber | undefined—Explicit total pages (used when totalItems is unknown)
variantvariantPaginationVariant'default'Visual style

Events

EventDescription
nana-page-changedetail: { page }
nana-page-size-changedetail: { pageSize }

CSS parts

PartDescription
::part(nav)The controls container
::part(ellipsis)The truncation gap (…)

CSS custom properties

PropertyDescription
--nana-pagination-radiusCorner radius of the page controls
--nana-pagination-active-bgActive page background (filled / pill)
--nana-pagination-active-colorActive page text colour (filled / pill)
EventTypeDescription
nana-page-changeCustomEventdetail: { page }
nana-page-size-changeCustomEventdetail: { pageSize }
VariableDescription
--nana-pagination-radiusCorner radius of the page controls
--nana-pagination-active-bgActive page background (filled / pill)
--nana-pagination-active-colorActive page text colour (filled / pill)
PartDescription
navThe controls container — every page-number and navigation button
ellipsisThe truncation gap (…) between page runs
  • Keyboard accessible
  • Screen-reader labels
  • Focus-visible states
  • ARIA roles and states
  • WCAG 2.2 AA contrast
Explore Pagination interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook