material-ui-pagination
An easy to use and customizable pagination component for material ui.
Play with this demo to see how it works.
Notice
Because some upstream modification about the click event made to the material-ui
repo, I have to make some changes in response.
You can check what I have done in issue16.
- Now for the newest version, you can install by
npm install material-ui-pagination@next
. - Otherwise go with the stable version by
npm install mateiral-ui-pagination
.
Quick Start
npm install material-ui-pagination
import Pagination from 'material-ui-pagination'
;
Usage
material-ui-pagination exposes one module called, Pagination
, which accepts a few props:
Option | Description |
---|---|
total |
Total number of pages |
display |
Number of pages you want to show in the panel |
current |
Current page selected |
onChange |
Handles the change event of selected page: function(value: integer) => void |
styleRoot |
Styles for root element |
styleFirstPageLink |
Styles for FirstPageLink . If not provided, a NavigationFirstPage from Material UI will be rendered as default, otherwise <div> with styles will show up instead |
styleLastPageLink |
Styles for LastPageLink . If not provided, a NavigationLastPage from Material UI will be rendered as default, otherwise <div> with styles will show up instead |
styleButton |
Styles for page number button. If not provided, a FlatButton from Material UI will be rendered as default, otherwise <div> with styles will show up instead |
stylePrimary |
Styles for active page element. Requires the styleButton |
Run Local Demo
git clone https://github.com/lo-tp/material-ui-pagination
npm install
npm run dev-server
- visit
http://localhost:7890/
Run test
git clone https://github.com/lo-tp/material-ui-pagination
npm install
npm run test
Code Example
;;;;;;Component{superprops;thissetTotal = thissetTotal;thissetDisplay = thissetDisplay;thisstate =total: 20display: 7number: 7;}{// eslint-disable-next-line no-param-reassigntotal = total;if totalif total !== ''// eslint-disable-next-line no-param-reassigntotal = ;else// eslint-disable-next-line no-param-reassigntotal = 0;this;}{// eslint-disable-next-line no-param-reassigndisplay = display;if displayif display !== ''// eslint-disable-next-line no-param-reassigndisplay = ;else// eslint-disable-next-line no-param-reassigndisplay = 0;this;}{return<divstyle =width: 500margin: '0 auto'><h3 >Now you are at<emstyle = color: 'red'>` `</em>page</h3><Paginationtotal = thisstatetotalcurrent = thisstatenumberdisplay = thisstatedisplayonChange = this/></div>;}ReactDOM;