Pagination
Page buttons with ellipses and previous/next.
Example
import { useState } from "react";
import { Pagination } from "@porcelana/ui";
export default function Example() {
const [page, setPage] = useState(5);
return <Pagination page={page} pageCount={12} onPageChange={setPage} />;
}Import
import { Pagination } from "@porcelana/ui";
import "@porcelana/ui/styles.css"; // once, at your app rootProps
Generated from the TypeScript types. Standard HTML attributes are passed through and not listed.
Pagination
| Prop | Type | Default | Description |
|---|---|---|---|
onPageChangerequired | (page: number) => void | – | Called with the 1-based page to show. |
pagerequired | number | – | Current page, 1-based. |
pageCountrequired | number | – | Total number of pages. |
aria-label | string | – | Defines a string value that labels the current element. @see aria-labelledby. |
id | string | – | Element id. Generated automatically when omitted. |
nextLabel | string | Next page | Accessible name of the next button. |
pageLabel | ((page: number) => string) | (p) => `Page ${p}` | Builds each page button's accessible name. |
previousLabel | string | Previous page | Accessible name of the previous button. |
siblingCount | number | 1 | Pages shown on each side of the current one before an ellipsis. |
Accessibility
- A nav landmark named Pagination; the current page has aria-current="page".
- Every button has a full name ("Page 5"); edge buttons disable at the ends.
Mobile
- 44px buttons; siblingCount controls how many pages show around the current one.