easy-react-modal

1.0.44 • Public • Published

easy-react-modal

wrap any react component with this Modal component and turn your component as modal.

Click for Demo.

Report issues here.

How to use it?

Step1:

npm install --save easy-react-modal

Step2: import the component

import Modal from 'easy-react-modal';

Step3: wrap your component which should open as modal. This can be react component or plain html tag.
                <Modal hide={true} close={callbackFn}>
                     <div>Great!!</div>
                </Modal>

Props.

  • hide=false to show the modal
  • hide=true to close it.
  • close={callbackFn} callback function which will toggle the above hide value. You can also perform additional task inside this function.

Optional Props.

  • styles={{background:'rgba(0,0,0,0.2)', container:'white'}} pass styles props to change the color of background and the container.
  • width={'100px'} pass width props to change the width of the container.

#Example

import React from 'react';
import ReactDOM from 'react-dom';
import Modal from 'easy-react-modal';


class App extends  React.Component {
    constructor() {
        super();    
        this.state = {
            modalOff: true
        }

        this.openModal = this.openModal.bind(this);
        this.closeModal = this.closeModal.bind(this);
    }

    openModal () {
        this.setState( {
            modalOff: false
        });
    }

    closeModal () {
        this.setState( {
            modalOff: true
        });
    }

    render() {
        return (
            <React.Fragment>
                <button onClick={this.openModal}>OPEN MODAL</button>

                <Modal hide={this.state.modalOff} close={this.closeModal} styles={{background:'rgba(0,0,0,0.2)', container:'white'}}>
                    <div>Great!!</div>
                </Modal>
            </React.Fragment>
        );
    }
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.442latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.442
1.0.430
1.0.421
1.0.410
1.0.400
1.0.390
1.0.380
1.0.370
1.0.360
1.0.350
1.0.340
1.0.330
1.0.320
1.0.310
1.0.300
1.0.290
1.0.280
1.0.270
1.0.260
1.0.250
1.0.240
1.0.231
1.0.220
1.0.210
1.0.200
1.0.190
1.0.170
1.0.160
1.0.150
1.0.140
1.0.130
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i easy-react-modal

Weekly Downloads

5

Version

1.0.44

License

ISC

Unpacked Size

5.83 kB

Total Files

5

Last publish

Collaborators

  • kenueteinnpm