React Smart Pagination Component
Smart Pagination
Documentation and examples for showing smart pagination to indicate a series of related content exists across multiple pages.
Other frameworks
CoreUI components are available as native Angular, Bootstrap (Vanilla JS), and Vue components. To learn more please visit the following pages.
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"
.???
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#
Looking to use an icon or symbol in place of text for some pagination links? SmartPagination will provide screen reader support for 'firstButton', 'previousButton', 'nextButton' and 'lastButton'.
Sizing#
Fancy larger or smaller pagination? Add size="lg"
or size="sm"
for additional sizes.
const [currentPage, setCurrentPage] = useState(1)return ( <CSmartPagination size="lg" activePage={currentPage} pages={10} onActivePageChange={setCurrentPage} />)
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"
flexbox utilities.
const [currentPage, setCurrentPage] = useState(1)return ( <CSmartPagination align="center" activePage={currentPage} pages={10} onActivePageChange={setCurrentPage} />)
const [currentPage, setCurrentPage] = useState(1)return ( <CSmartPagination align="end" activePage={currentPage} pages={10} onActivePageChange={setCurrentPage} />)
API#
CSmartPagination#
import { CSmartPagination } from '@coreui/react-pro'// orimport CSmartPagination from '@coreui/react-pro/src/components/smart-pagination/CSmartPagination'
Property | Description | Type | Default |
---|---|---|---|
activePage | Current page number. | number | 1 |
align | Horizontall align. | 'start' | 'center' | 'end' | start |
arrows | Show/hide arrows. | boolean | true |
className | A string of all className you want applied to the base component. | string | - |
dots | Show/hide dots. | boolean | true |
doubleArrows | Show double arrows buttons. | boolean | true |
firstButton | The content of 'firstButton' button. | ReactNode | <React.Fragment>«</React.Fragment> |
lastButton | The content of 'lastButton' button. | ReactNode | <React.Fragment>»</React.Fragment> |
limit | Maximum items number. | number | 5 |
nextButton | The content of 'nextButton' button. | ReactNode | <React.Fragment>›</React.Fragment> |
onActivePageChange | On active page change callback. | (activePage: number) => void | - |
pages | Number of pages. | number | - |
previousButton | The content of 'previousButton' button. | ReactNode | <React.Fragment>‹</React.Fragment> |
size | Size of pagination, valid values: 'sm', 'lg'. | 'sm' | 'lg' | - |