Pagination
React Bootstrap 5 Pagination
React Bootstrap 5 Pagination is a component used to indicate a series of related content across multiple pages and enables navigation across them.
We use a large block of connected links for our pagination, making links hard to miss and easily scalable while providing large hit areas. Pagination is built with a list of HTML elements so screen readers can announce the number of available links. We use a wrapping <nav>
element to identify it as a navigation section to screen readers and other assistive technologies.
Importing the React Bootstrap 5 Pagination Component
To use the Contrast React Bootstrap 5 Pagination component, you import CDBPagination
into your project.
import { CDBPagination } from "cdbreact";
Alongside the CDBPagination
component, we also import the CDBPageItem
, representing an item in the CDBPagination
component. Next, we imported the CDBPageLink
component, this component acts as a link.
import { CDBPagination, CDBPageLink, CDBPageItem, CDBContainer } from "cdbreact";
Default Pagination
import React from "react";import { CDBPagination, CDBPageLink, CDBPageItem, CDBContainer } from "cdbreact";
const Pagination = () => { return ( <CDBContainer> <CDBPagination circle> <CDBPageLink>Prev</CDBPageLink> <CDBPageItem>1</CDBPageItem> <CDBPageItem>2</CDBPageItem> <CDBPageItem>3</CDBPageItem> <CDBPageLink>Next</CDBPageLink> </CDBPagination> <CDBPagination circle size="big" color="success"> <CDBPageLink>Prev</CDBPageLink> <CDBPageItem>1</CDBPageItem> <CDBPageItem>2</CDBPageItem> <CDBPageItem>3</CDBPageItem> <CDBPageLink>Next</CDBPageLink> </CDBPagination> <CDBPagination size="small" color="secondary"> <CDBPageLink>Prev</CDBPageLink> <CDBPageItem>1</CDBPageItem> <CDBPageItem>2</CDBPageItem> <CDBPageItem>3</CDBPageItem> <CDBPageLink>Next</CDBPageLink> </CDBPagination> <CDBPagination color="warning" sm> <CDBPageLink>Prev</CDBPageLink> <CDBPageItem>1</CDBPageItem> <CDBPageItem>2</CDBPageItem> <CDBPageItem>3</CDBPageItem> <CDBPageLink>Next</CDBPageLink> </CDBPagination> <CDBPagination color="white" sm> <CDBPageLink>Prev</CDBPageLink> <CDBPageItem>1</CDBPageItem> <CDBPageItem>2</CDBPageItem> <CDBPageItem>3</CDBPageItem> <CDBPageLink>Next</CDBPageLink> </CDBPagination> <CDBPagination color="light"> <CDBPageLink>Prev</CDBPageLink> <CDBPageItem>1</CDBPageItem> <CDBPageItem>2</CDBPageItem> <CDBPageItem>3</CDBPageItem> <CDBPageLink>Next</CDBPageLink> </CDBPagination> <CDBPagination color="danger"> <CDBPageLink>Prev</CDBPageLink> <CDBPageItem>1</CDBPageItem> <CDBPageItem>2</CDBPageItem> <CDBPageItem>3</CDBPageItem> <CDBPageLink>Next</CDBPageLink> </CDBPagination> <CDBPagination> <CDBPageLink>Prev</CDBPageLink> <CDBPageItem>1</CDBPageItem> <CDBPageItem>2</CDBPageItem> <CDBPageItem>3</CDBPageItem> <CDBPageLink>Next</CDBPageLink> </CDBPagination> </CDBContainer> );};export default Pagination;
API Reference: Contrast React Bootstrap 5 Pagination Props
This section will build on your information about the props you get to use with the Contrast React Bootstrap 5 Pagination component. You will find out what these props do, their default values, and how you would use them in your code.
The table below lists other prop options of the CDBPagination
component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
className | String | Adds custom classes | Adds custom classes | <CDBPagination className="myClass" ... /> |
tag | String | ul | Changes default pagination tag | <CDBPagination tag="ol" ... /> |
size | String | Changes size of pagination component. Choose from lg and sm | <CDBPagination size="sm" ... /> | |
sm | Boolean | false | Changes the size of pagination component to sm | <CDBPagination sm .../> |
circle | Boolean | false | Changes the shape of pagination component to circular | <CDBPagination circle .../> |
color | String | dark | Changes default pagination buttons color; available values: [blue, red, teal, dark-grey, dark, blue-grey, amber, purple] | <CDBPagination color="red" ... /> |
API Reference: Contrast React Bootstrap 5 Pagination Item Props
The table below lists other prop options of the CDBPageItem
component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
className | String | Adds custom classes | <CDBPageItem className="myClass" ... /> | |
tag | String | li | Changes default pagination tag | <CDBPageItem tag="li" ... /> |
disable | Boolean | false | Disables item from being clicked | <CDBPageItem disabled .../> |
active | Boolean | false | Sets active state of the button | <CDBPageItem active .../> |
API Reference: Contrast React Bootstrap 5 Pagination Link Props
The table below lists other prop options of the CDBPageLink
component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
className | String | Adds custom classes | <CDBPageLink className="myClass" ... /> | |
tag | String | li | Changes default pagination tag | <CDBPageLink tag="li" ... /> |
disable | Boolean | false | Disables item from being clicked | <CDBPageLink disabled .../> |
active | Boolean | false | Sets active state of the button | <CDBPageLink active .../> |
Build modern projects using Bootstrap 5 and Contrast
Trying to create components and pages for a web app or website from
scratch while maintaining a modern User interface can be very tedious.
This is why we created Contrast, to help drastically reduce the amount of time we spend doing that.
so we can focus on building some other aspects of the project.
Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants.
Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for
building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.