Documentation and examples for showing smart pagination to indicate a series of related content exists across multiple 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".???

1const [currentPage, setCurrentPage] = useState(1)
2return <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.

1const [currentPage, setCurrentPage] = useState(1)
2return (
3 <CSmartPagination
4 size="lg"
5 activePage={currentPage}
6 pages={10}
7 onActivePageChange={setCurrentPage}
8 />
9)
1const [currentPage, setCurrentPage] = useState(1)
2return (
3 <CSmartPagination
4 size="sm"
5 activePage={currentPage}
6 pages={10}
7 onActivePageChange={setCurrentPage}
8 />
9)

Alignment#

Change the alignment of pagination components with align="start", align="center" or align="end" flexbox utilities.

1const [currentPage, setCurrentPage] = useState(1)
2return (
3 <CSmartPagination
4 align="center"
5 activePage={currentPage}
6 pages={10}
7 onActivePageChange={setCurrentPage}
8 />
9)
1const [currentPage, setCurrentPage] = useState(1)
2return (
3 <CSmartPagination
4 align="end"
5 activePage={currentPage}
6 pages={10}
7 onActivePageChange={setCurrentPage}
8 />
9)

API#

CSmartPagination#

1import { CSmartPagination } from '@coreui/react-pro'
2// or
3import CSmartPagination from '@coreui/react-pro/src/components/pagination/CSmartPagination'
PropertyDescriptionTypeDefault
activePageCurrent page number.number1
alignHorizontall align.'start' | 'center' | 'end'start
arrowsShow/hide arrows.booleantrue
classNameA string of all className you want applied to the base component.string-
dotsShow/hide dots.booleantrue
doubleArrowsShow double arrows buttons.booleantrue
firstButtonThe content of 'firstButton' button.ReactNode<React.Fragment>«</React.Fragment>
lastButtonThe content of 'lastButton' button.ReactNode<React.Fragment>»</React.Fragment>
limitMaximum items number.number5
nextButtonThe content of 'nextButton' button.ReactNode<React.Fragment>›</React.Fragment>
onActivePageChangeOn active page change callback.(a: number, b?: boolean) => void-
pagesNumber of pages.number-
previousButtonThe content of 'previousButton' button.ReactNode<React.Fragment>‹</React.Fragment>
sizeSize of pagination, valid values: 'sm', 'lg'.'sm' | 'lg'-