Command palette

@yasinsensoy/native

React Native · Components

Pagination

Pagination: numbered buttons, previous/next, a compact view or "show more".

3 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

Code

import { Pagination } from "@yasinsensoy/native";

const [page, setPage] = useState(1);

<Pagination
  page={page}
  total={245}
  onPageChange={setSayfa}
/>

Events

  1. Events appear here when you interact with the preview.

In a table: sorting + page size + summary (Table pagination)

OrdersStatus
#4200Ayşe YılmazPaid$120.00
#4201Mehmet KayaReturned$3,239.00
#4202Zeynep DemirPaid$1,558.00
#4203Can ŞahinPaid$4,677.00
#4204Elif ÇelikPending$2,996.00
#4205Emre AkPaid$1,315.00
#4206Ayşe YılmazPaid$4,434.00
#4207Mehmet KayaPaid$2,753.00
#4208Zeynep DemirPending$1,072.00
#4209Can ŞahinPaid$4,191.00

1–10 of 137

Per page

Your own grid: usePagination, scrolls to the top of the list on change

Product 1

Product 2

Product 3

Product 4

Product 5

Product 6

Product 7

Product 8

1–8 of 58

Per page

Cursor API, total unknown: useCursorPagination

Show more (variant="more"), async

Narrow card: compact, pick by searching across 10,000 pages

Archive

Linked: Next.js server component, page from the URL (?page=)

A table paged on the server; pages are real links, the filter parameter is kept, on the first page ?page=1 isn't written.

Open the server example

Simple, with text: previous / next

Import

import { Pagination } from "@yasinsensoy/native";

Pagination

component

Pagination: numbered buttons, previous/next, a compact view or "show more". The page calculations are the same as web (@yasinsensoy/core/pagination); the button count stays fixed when the page changes, so nothing slides out from under the finger. Touch areas are at least 44 px.

Pagination({ page: pageProp, defaultPage, onPageChange, total, pageCount: pageCountProp, hasNext: hasNextProp, pageSize, variant, siblings, boundaries, firstLast, summary, size, activeVariant, align, hideOnSinglePage, disabled, label, style, }: PaginationProps): JSX.Element | null

Examples

<Pagination total={245} pageSize={20} page={page} onPageChange={setPage} />
<Pagination variant="compact" pageCount={12} />
<Pagination variant="more" total={245} pageSize={20} onPageChange={loadMore} />

Look of the pagination (same as web).

  • pages: numbered page buttons with … in the gaps.
  • simple: only previous / next and "Page 3 / 12".
  • compact: arrows with "3 / 12" in the middle.
  • more: a "Show more" button (instead of an infinite list).
type PaginationVariant = "pages" | "simple" | "compact" | "more"

Props of Pagination.

NameTypeDefaultDescription
page?numberThe current page (controlled, starts at 1).
defaultPage?number1Initial page.
onPageChange?(page: number) => unknownWhen the page changes; if it returns a Promise the button spins until it finishes.
total?numberTotal records; the page count is computed with pageSize.
pageCount?numberTotal pages (instead of total).
hasNext?booleanfalseWhen the total is unknown (cursor APIs), whether there is a next page.
pageSize?number10Records per page.
variant?PaginationVariant"pages"Variant.
siblings?number1Number of pages on each side of the current page.
boundaries?number1Pages always visible at the start and end.
firstLast?booleanfalseFirst / last page buttons.
summary?boolean | ((info: PageInfo) => ReactNode)Record range summary ("1–20 of 245"); needs total.
size?Size"md"Button size.
activeVariant?"solid" | "soft" | "outline""solid"Style of the selected page.
align?"start" | "center" | "end" | "between""center"Alignment.
hideOnSinglePage?booleanfalseNot drawn at all when there is a single page.
disabled?booleanDisabled.
label?string{@link UIProvider} `pages` textScreen reader name.
style?StyleProp<ViewStyle>Container style.