YuhuanStudioYunUIDocs
Patterns

Simple Pagination

A prev / page-indicator / next pager for cursor- or has-more lists where the total page count isn't known.

A previous / page-indicator / next pager for cursor- or has-more-style lists where the total page count isn't known, so BlogPagination's numbered pages don't apply. It is controlled — the host owns paging through onPrevious / onNext, and hasNext drives whether the next button is enabled.

Import

import { SimplePagination } from "@yuhuanowo/yunui/patterns";

Example

The handlers are functions, which can't cross the server→client boundary in MDX, so the example is rendered from a small client wrapper that tracks the current page in state. hasNext is computed from the host's "is there a next cursor?" — here a fixed 5-page cap.

SimplePagination

Page 1

When to use which pager

  • SimplePagination — cursor / has_more APIs with no total: prev, a page indicator, next. Use this when you only know whether there's a next page.
  • BlogPagination — you know the total page count and want numbered pages with ellipses.
  • Pagination (primitive) — the lower-level controlled pager the patterns build on.

Props

PropTypeDefaultDescription
currentPage*number1-indexed current page, shown in the centre indicator.
hasNext*booleanWhether a next page exists — cursor-style, for lists with no known total.
hasPreviousbooleanWhether a previous page exists. Defaults to `currentPage > 1`.
labels{ previous?: string; next?: string; page?: ((n: number) => ReactNode) | undefined; } | undefinedLocalized labels. `page` renders the centre indicator (default `Page {n}`).
onNext*() => void
onPrevious*() => void

On this page