Code Monkey home page Code Monkey logo

react-responsive-modal's Introduction

react-responsive-modal

A simple responsive react modal.

Build Status

You can find a demo here. Or you can run examples

git clone https://github.com/pradel/react-responsive-modal
cd react-responsive-modal
yarn
yarn run build:examples
open examples/index.html

Installation

With npm: npm install react-responsive-modal --save

Or with yarn: yarn add react-responsive-modal

Usage

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

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.onOpenModal = this.onOpenModal.bind(this);
    this.onCloseModal = this.onCloseModal.bind(this);
    this.state = {
      open: false,
    };
  }

  onOpenModal() {
    this.setState({ open: true });
  }

  onCloseModal() {
    this.setState({ open: false });
  }

  render() {
    const { open } = this.state;
    return (
      <div>
        <button onClick={this.onOpenModal}>Open modal</button>
        <Modal open={open} onClose={this.onCloseModal} little>
          <h2>Simple centered modal</h2>
        </Modal>
      </div>
    );
  }
}

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

Props

open: (Bool) Required Control if the modal is open or not.

onClose: (Function) Required Fired when the Modal is requested to be closed by a click on the overlay or when user press esc key.

closeOnEsc: (Bool) default: true is the modal closable when user press esc key.

closeOnOverlayClick: (Bool) default: true is the modal closable when user click on overlay.

little: (Bool) Is the dialog centered When you don't have a lot of content.

showCloseIcon: (Bool) default: true Show the close icon.

closeIconSize: (Number) default: 28 Close icon size.

children: (Node) The content of the modal.

overlayClassName: (String) Classname for overlay div.

modalClassName: (String) Classname for modal content div.

closeIconClassName: (String) Classname for close icon svg.

overlayStyle: (Object) Inline style for overlay div.

modalStyle: (Object) Inline style for modal content div.

react-responsive-modal's People

Contributors

amertak avatar pradel avatar russellmorgan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.