Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

material-ui-pagination

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

material-ui-pagination

An easy to use and customizable pagination component for material ui.

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
611
increased by59.53%
Maintainers
1
Weekly downloads
 
Created
Source

material-ui-pagination

Build Status

An easy to use and customizable pagination component for material ui.

Play with this demo to see how it works.

Demonstration

Quick Start


  • npm install material-ui-pagination
  • import Pagination from 'material-ui-pagination';

Usage


material-ui-pagination exposes one module called, Pagination, which accepts 4 props:

  • 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

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


import React from 'react';
import ReactDOM from 'react-dom';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import injectTapEventPlugin from 'react-tap-event-plugin';
import Pagination from 'material-ui-pagination';

injectTapEventPlugin();

class App extends React.Component {
  constructor(props) {
    super(props);
    this.setTotal = this.setTotal.bind(this);
    this.setDisplay = this.setDisplay.bind(this);
    this.state = {
      total: 20,
      display: 7,
      number: 7,
    };
  }

  setTotal(event, total) {
    // eslint-disable-next-line no-param-reassign
    total = total.trim();
    if (total.match(/^\d*$/)) {
      if (total !== '') {
        // eslint-disable-next-line no-param-reassign
        total = parseInt(total, 10);
      } else {
        // eslint-disable-next-line no-param-reassign
        total = 0;
      }

      this.setState({ total });
    }
  }

  setDisplay(event, display) {
    // eslint-disable-next-line no-param-reassign
    display = display.trim();
    if (display.match(/^\d*$/)) {
      if (display !== '') {
        // eslint-disable-next-line no-param-reassign
        display = parseInt(display, 10);
      } else {
        // eslint-disable-next-line no-param-reassign
        display = 0;
      }

      this.setState({ display });
    }
  }

  render() {
    return (
      <div
        style = { {
          width: 500,
          margin: '0 auto',
        } }
      >
        <h3 >
          Now you are at
          <em
            style = { { color: 'red' } }
          >
            {` ${this.state.number} ` }
          </em>
          page
        </h3>
        <Pagination
          total = { this.state.total }
          current = { this.state.number }
          display = { this.state.display }
          onChange = { number => this.setState({ number }) }
        />
      </div>
    );
  }
}

ReactDOM.render(
  <MuiThemeProvider >
    <App />
  </MuiThemeProvider>,
  document.getElementById('root')
);

Keywords

FAQs

Package last updated on 16 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc