Examples
Controlled page
The feature owns the current page and can use it to derive the visible slice of rows.
Controlled pagination for 42 items
"use client";
import { useState } from "react";
import { Pagination } from "@phuctech/ui/components/pagination";
export function Example() {
const [page, setPage] = useState(2);
return <Pagination count={42} pageSize={5} page={page} onPageChange={setPage} />;
}
Uncontrolled page
Use defaultPage when the pagination does not need to be mirrored into feature state.
Uncontrolled pagination with page two selected
import { Pagination } from "@phuctech/ui/components/pagination";
export function Example() {
return <Pagination count={42} pageSize={5} defaultPage={2} />;
}
Try the props
Change the total count and disabled state while the control owns its initial page.
Pagination property playground
import { Pagination } from "@phuctech/ui/components/pagination";
export function Example() {
return <Pagination count={42} pageSize={5} defaultPage={2} />;
}When to use
Use Pagination when the person needs to move through a known result set. It only reports the requested page; the feature decides which records to render or fetch. Keep filters staged when the screen has an Apply action.
Usage
import { Pagination } from "@phuctech/ui/components/pagination";
<Pagination count={42} pageSize={10} page={page} onPageChange={setPage} />API
Tokens
Accessibility
Pagination is a named navigation landmark. Every page button has an action-oriented accessible name; the current page uses aria-current="page", and range changes are announced politely. Buttons work with Tab, Enter, and Space.
Do and don’t
Reset the page in feature state when filters change the result set.
Put data loading or per-row requests inside Pagination.
Related
- Table presents structured rows.
- Data Table composes staged filters, selection, and pagination.