An open API service indexing awesome lists of open source software.

https://github.com/ninsau/react-pagination-component

A simple pagination component to use inside your react projects
https://github.com/ninsau/react-pagination-component

pagination-component pagination-library react-pagination reactjs

Last synced: 3 months ago
JSON representation

A simple pagination component to use inside your react projects

Awesome Lists containing this project

README

        

# react-pagination-component

A simple pagination component to use inside your react projects.

## Demo

![pagination component](https://res.cloudinary.com/deyudesls/image/upload/c_scale,q_100,w_527/v1627897538/pagination-component/Screen_Shot_2021-08-02_at_9.45.00_AM_ajqoei.gif)

[Demo](https://csb-pg8kq-g5szse1c7-ninsau.vercel.app/)

View sample code on [codesandbox](https://codesandbox.io/s/pagination-for-reactjs-pg8kq?file=/src/App.js).

## How to use

### Install

```
1. npm i pagination-for-reactjs-component --save
```

### 2. Import pagination component inside react

- With bootstrap design

```
import Pagination from 'pagination-for-reactjs-component'
import "bootstrap/dist/css/bootstrap.min.css";
```

- With material ui

```
import MuiPagination from 'pagination-for-reactjs-component/mui'
```

### 3. Call the pagination function and pass parameters

Inside your render or return

- for bootstrap

```

```

- for material ui

```

```

### 4. Definitions

- pageCount

```
(variable, type:integer), pass the value of the total number of pages or numbers for your pagination
```

- pageIndex

```
(variable, type:integer), pass the value of the current page number within your series.
```

- setPageIndex

```
(function, react hook), this hook receives intergers to pass to pageIndex for navigation
```

### 5. Custom styling

- Top style, access the `pagination` css class and implement your design
- Default styling

```
.pagination {
display: flex;
padding-left: 0;
list-style: none;
}

ul {
display: block;
list-style-type: disc;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
padding-inline-start: 40px;
}
```

### 6. Sample Code

```
import { React, useState } from "react";
import Pagination from "pagination-for-reactjs-component";
import MuiPagination from "pagination-for-reactjs-component/mui";
import "bootstrap/dist/css/bootstrap.min.css";

export default function App() {
const [pageIndex, setPageIndex] = useState(1);
let pageCount = 200;

return (
<>


You are on page {pageIndex}

bootstrap design

material ui design


>
);
}

```