Display a series of buttons to navigate through a list of items.
import { Pagination } from '@fluxui-dev/react';// orders: Order::paginate(), passed as a page prop<Pagination paginator={orders} />
Use the simple paginator when working with large datasets where counting the total number of results would be expensive. The simple paginator provides "Previous" and "Next" buttons without displaying the total number of pages or records.
// orders: Order::simplePaginate(), passed as a page prop<Pagination paginator={orders} />
When working with large result sets, the pagination component automatically adapts to show a reasonable number of page links. It shows the first and last pages, along with a window of pages around the current page, and adds ellipses for any gaps to ensure efficient navigation through numerous pages.
// orders: Order::paginate(5), passed as a page prop<Pagination paginator={orders} />
<Pagination paginator={orders} scrollTo />
<Pagination paginator={orders} scrollTo="#table" />
Pass onPageChange to handle page changes yourself, such as for data that's already loaded, and build the paginator from your own state.
import { useState } from 'react';const [page, setPage] = useState(1);<Pagination paginator={{ current_page: page, last_page: 10, total: 95, from: (page - 1) * 10 + 1, to: Math.min(page * 10, 95) }} onPageChange={setPage}/>
|
Prop
|
Description
|
|---|---|
| paginator |
The paginator to display: what Laravel's paginate(), simplePaginate(), or cursorPaginate() returns, or an API resource collection of one. Page links navigate through the link registered in FluxProvider.
|
| onPageChange |
Callback fired with the page number when a page button is clicked, instead of following the paginator's URLs. Ignored for cursor paginators.
|
| scrollTo |
Scroll to an element when a pagination button is clicked. Pass a CSS selector to target a specific element. Default: body.
|
| className |
CSS classes applied to the pagination's root element.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-pagination |
Applied to the root element for styling and identification.
|