The <Pagination> component displays pagination controls to navigate through search result pages.
Import
import { Pagination } from 'react-instantsearch';
Props
Number of page buttons to display on each side of the current page.<Pagination padding={2} />
Maximum number of pages to display.<Pagination totalPages={20} />
Whether to display the “First” button.<Pagination showFirst={false} />
Whether to display the “Previous” button.<Pagination showPrevious={false} />
Whether to display the “Next” button.<Pagination showNext={false} />
Whether to display the “Last” button.<Pagination showLast={false} />
Customize the text strings.<Pagination
translations={{
firstPageItemText: 'First',
previousPageItemText: 'Previous',
nextPageItemText: 'Next',
lastPageItemText: 'Last',
pageItemText: ({ currentPage }) => `${currentPage}`,
firstPageItemAriaLabel: 'First Page',
previousPageItemAriaLabel: 'Previous Page',
nextPageItemAriaLabel: 'Next Page',
lastPageItemAriaLabel: 'Last Page',
pageItemAriaLabel: ({ currentPage }) => `Page ${currentPage}`,
}}
/>
CSS classes to customize the component styling.
Example
import { InstantSearch, SearchBox, Hits, Pagination } from 'react-instantsearch';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
const searchClient = algoliasearch(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
function App() {
return (
<InstantSearch searchClient={searchClient} indexName="products">
<SearchBox />
<Hits />
<Pagination />
</InstantSearch>
);
}
function App() {
return (
<InstantSearch searchClient={searchClient} indexName="products">
<Hits />
<Pagination
showFirst={false}
showLast={false}
padding={2}
/>
</InstantSearch>
);
}