2.0.6 • Published 6 years ago

react-modal-button v2.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Installation

npm i --save react-modal-button

Example

Demo here - Codesandbox.io

Usage

import React from 'react';
import { ModalButton } from 'react-modal-button';

const App = () => (
  <div>
    <h1>React Modal Button!</h1>

    <ModalButton
      modal={({ closeModal }) => (
        <div>
          <p>My Modal</p>
          <button onClick={closeModal}>Close</button>
        </div>
      )}
    >
      Button Text Here 🐕
    </ModalButton>
  </div>
);

Props for content

proprender prop
modalcloseModal

Props on Button

propsdefualt
buttonStyle
buttonClassName

Props for Modal

propsDefault
isBackdropfalse
showCloseButtontrue
closeOnBackdroptrue
closeOnEsctrue
height'300px'
width'500px'
animation'fade'
animationDurationMS300
className
windowClassName
windowStyles
backdropClassName
backdropStyles

Custom Animation

modal-[your-animation-prop]-on-[enter/leave]

Control the modal with state

import { Modal } from 'react-modal-button';

class App extends Component {
  state = {
    isModalOpen: false,
  };

  openModal = () => {
    this.setState({ isModalOpen: true });
  };

  closeModal = () => {
    this.setState({ isModalOpen: false });
  };

  render() {
    return (
      <div>
        <button onClick={this.openModal}>Open Modal</button>

        <Modal isOpen={this.state.isModalOpen} onClose={this.closeModal}>
          <div>Content</div>
          <button onClick={this.closeModal}>Close Modal</button>
        </Modal>
      </div>
    );
  }
}
2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago