Documentation and examples for showing smart pagination to indicate a series of related content exists across multiple pages.
Available in Other JavaScript Frameworks
CoreUI React Smart Pagination Component is also available for Angular and Vue. Explore framework-specific implementations below:
Overview
React smart pagination component consists of button-like styled links, that are arranged side by side in a horizontal list.
We use a large block of connected links for our pagination, making links hard to miss and easily scalable—all while providing large hit areas. SmartPagination is built with list HTML elements so screen readers can announce the number of available links. SmartPagination also use a wrapping <nav> element to identify it as a navigation section to screen readers and other assistive technologies.
In addition, as pages likely have more than one such navigation section, SmartPagination provide a descriptive aria-label for the <nav> to reflect its purpose. For example, if the pagination component is used to navigate between a set of search results, an appropriate label could be aria-label="Search results pages".
import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
export const SmartPaginationExample = () => {
const [currentPage, setCurrentPage] = useState(1)
return (
<CSmartPagination activePage={currentPage} pages={10} onActivePageChange={setCurrentPage} />
)
}import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
export const SmartPaginationExample = () => {
const [currentPage, setCurrentPage] = useState(1)
return (
<CSmartPagination activePage={currentPage} pages={10} onActivePageChange={setCurrentPage} />
)
}Features
- Determine behavior, style and functionality of pagination
- Smart automatic items generation
Working with icons
The four navigation buttons take their content from firstButton, previousButton, nextButton and lastButton. A string is rendered as HTML — that is where the default « and friends come from — so pass a node instead to put an icon there.
Mark the icon aria-hidden: the buttons already carry their own accessible names, and an icon announced on top of them would read twice.
import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
import CIcon from '@coreui/icons-react'
import {
cilChevronDoubleLeft,
cilChevronDoubleRight,
cilChevronLeft,
cilChevronRight,
} from '@coreui/icons'
export const SmartPaginationIconsExample = () => {
const [activePage, setActivePage] = useState(3)
return (
<CSmartPagination
activePage={activePage}
pages={10}
onActivePageChange={setActivePage}
doubleArrows
firstButton={<CIcon icon={cilChevronDoubleLeft} aria-hidden="true" />}
previousButton={<CIcon icon={cilChevronLeft} aria-hidden="true" />}
nextButton={<CIcon icon={cilChevronRight} aria-hidden="true" />}
lastButton={<CIcon icon={cilChevronDoubleRight} aria-hidden="true" />}
/>
)
}import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
import CIcon from '@coreui/icons-react'
import {
cilChevronDoubleLeft,
cilChevronDoubleRight,
cilChevronLeft,
cilChevronRight,
} from '@coreui/icons'
export const SmartPaginationIconsExample = () => {
const [activePage, setActivePage] = useState(3)
return (
<CSmartPagination
activePage={activePage}
pages={10}
onActivePageChange={setActivePage}
doubleArrows
firstButton={<CIcon icon={cilChevronDoubleLeft} aria-hidden="true" />}
previousButton={<CIcon icon={cilChevronLeft} aria-hidden="true" />}
nextButton={<CIcon icon={cilChevronRight} aria-hidden="true" />}
lastButton={<CIcon icon={cilChevronDoubleRight} aria-hidden="true" />}
/>
)
}Sizing
Fancy larger or smaller pagination? Add size="lg" or size="sm" for additional sizes.
import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
export const SmartPaginationSizingLargeExample = () => {
const [currentPage, setCurrentPage] = useState(1)
return (
<CSmartPagination
size="lg"
activePage={currentPage}
pages={10}
onActivePageChange={setCurrentPage}
/>
)
}import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
export const SmartPaginationSizingLargeExample = () => {
const [currentPage, setCurrentPage] = useState(1)
return (
<CSmartPagination
size="lg"
activePage={currentPage}
pages={10}
onActivePageChange={setCurrentPage}
/>
)
}import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
export const SmartPaginationSizingSmallExample = () => {
const [currentPage, setCurrentPage] = useState(1)
return (
<CSmartPagination
size="sm"
activePage={currentPage}
pages={10}
onActivePageChange={setCurrentPage}
/>
)
}import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
export const SmartPaginationSizingSmallExample = () => {
const [currentPage, setCurrentPage] = useState(1)
return (
<CSmartPagination
size="sm"
activePage={currentPage}
pages={10}
onActivePageChange={setCurrentPage}
/>
)
}Alignment
Change the alignment of pagination components with align="start", align="center" or align="end".
import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
export const SmartPaginationAlignmentCenterExample = () => {
const [currentPage, setCurrentPage] = useState(1)
return (
<CSmartPagination
align="center"
activePage={currentPage}
pages={10}
onActivePageChange={setCurrentPage}
/>
)
}import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
export const SmartPaginationAlignmentCenterExample = () => {
const [currentPage, setCurrentPage] = useState(1)
return (
<CSmartPagination
align="center"
activePage={currentPage}
pages={10}
onActivePageChange={setCurrentPage}
/>
)
}import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
export const SmartPaginationAlignmentEndExample = () => {
const [currentPage, setCurrentPage] = useState(1)
return (
<CSmartPagination
align="end"
activePage={currentPage}
pages={10}
onActivePageChange={setCurrentPage}
/>
)
}import React, { useState } from 'react'
import { CSmartPagination } from '@coreui/react-pro'
export const SmartPaginationAlignmentEndExample = () => {
const [currentPage, setCurrentPage] = useState(1)
return (
<CSmartPagination
align="end"
activePage={currentPage}
pages={10}
onActivePageChange={setCurrentPage}
/>
)
}API
Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here.
