- Docs
- Components
- Navigation
Pagination
Pages of a long list, for offset and limit APIs: the range on show, then First, Previous, Next and Last.
- Import
- @qeetrix/react/experimental
- Status
- ExperimentalSince 0.0.6
- Renders
<nav aria-label="Pagination">Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Playground
Every prop, live, and the code it takes.
import { Pagination } from "@qeetrix/react/experimental";
const [offset, setOffset] = useState(0);
<Pagination
offset={offset}
pageSize={25}
total={1284}
onOffsetChange={setOffset}
/>02
With a total
offset and pageSize, as the API takes them: the range, announced as it changes, then First, Previous, Next and Last.
const [offset, setOffset] = useState(25);
<Pagination offset={offset} pageSize={25} total={1284} onOffsetChange={setOffset} />03
Without a total
For an API that doesn't count: no Last, and Next stays on while a full page comes back.
<Pagination offset={offset} pageSize={25} itemsOnPage={rows.length} onOffsetChange={setOffset} />04
Cursor paging
hasPrevious and hasNext, for an API that gives the next cursor: Previous and Next alone.
<Pagination
offset={offset}
pageSize={25}
hasPrevious={cursors.length > 0}
hasNext={Boolean(data?.next)}
onPrevious={back}
onNext={() => forward(data.next)}
/>05
Show more
ShowMore appends the next page under a growing list, then says there's no more.
<ShowMore
hasMore={Boolean(data?.next)}
loading={isFetching}
onMore={() => fetchNext()}
label="Show older events"
end="That's everything since 29 September."
/>06
Rows per page
pageSizes offers a select; onPageSizeChange takes the new size, back on the first page.
<Pagination
offset={offset}
pageSize={pageSize}
total={1284}
onOffsetChange={setOffset}
pageSizes={[25, 50, 100]}
onPageSizeChange={(size) => {
setPageSize(size);
setOffset(0);
}}
/>07
Loading
loading turns the buttons off while the next page comes.
<Pagination offset={offset} pageSize={25} total={1284} loading onOffsetChange={setOffset} />08
Under a table
In a Card's footer: the rows and the bar move together.
Users
| Name | Status |
|---|---|
| Priya Sharma | Active |
| Rahul Reddy | Active |
| Ananya Rao | Active |
| Vikram Nair | Invited |
| Meera Joshi | Suspended |
<Card
title="Users"
footer={<Pagination offset={offset} pageSize={pageSize} total={users.length} onOffsetChange={setOffset} />}
>
<Table label="Users" rows={users.slice(offset, offset + pageSize)} … />
</Card>09
In Hindi
QeetrixProvider's messages and locale: the strings, and the numbers grouped for India.
import { hi } from "@qeetrix/react/locales/hi";
<QeetrixProvider locale="hi-IN" messages={hi}>
<Pagination offset={0} pageSize={25} total={128400} onOffsetChange={setOffset} />
</QeetrixProvider>