Giter Site home page Giter Site logo

nuruzzamancse / react-responsive-modal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pradel/react-responsive-modal

0.0 2.0 0.0 1.77 MB

Simple responsive react modal

Home Page: https://react-responsive-modal.leopradel.com/

License: MIT License

JavaScript 94.17% CSS 3.56% TypeScript 2.26%

react-responsive-modal's Introduction

react-responsive-modal

npm version npm Build Status codecov dependencies Status

A simple responsive react modal compatible with React 15, 16 and ready for React 17.

  • Centered modals.
  • Scrolling modals.
  • Multiple modals.
  • Easily customizable via props.

Demo

You can find a demo here.

Examples

https://react-responsive-modal.leopradel.com/#example

Installation

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

Or with yarn: yarn add react-responsive-modal

Usage

Edit react-responsive-modal

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

export default class App extends React.Component {
  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} center>
          <h2>Simple centered modal</h2>
        </Modal>
      </div>
    );
  }
}

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

Props

Modal

Name Type Default Description
closeOnEsc bool true Is the modal closable when user press esc key.
closeOnOverlayClick bool true Is the modal closable when user click on overlay.
onEntered func null Callback fired when the Modal is open and the animation is finished.
onExited func null Callback fired when the Modal has exited and the animation is finished.
onClose* func Callback fired when the Modal is requested to be closed by a click on the overlay or when user press esc key.
onEscKeyDown func null Callback fired when the escape key is pressed.
onOverlayClick func null Callback fired when the overlay is clicked.
open* bool Control if the modal is open or not.
classNames object An object containing classNames to style the modal, can have properties 'overlay' (classname for overlay div), 'modal' (classname for modal content div), 'closeButton' (classname for the button that contain the close icon), 'closeIcon' (classname for close icon svg). You can customize the transition with 'transitionEnter', 'transitionEnterActive', 'transitionExit', 'transitionExitActive'
styles object An object containing the styles objects to style the modal, can have properties 'overlay', 'modal', 'closeButton', 'closeIcon'.
children node null The content of the modal.
center bool false Should the dialog be centered.
showCloseIcon bool true Show the close icon.
closeIconSize number 28 Close icon size.
closeIconSvgPath node <path d="M28.5 9.62L26.38 7.5 18 15.88 9.62 7.5 7.5 9.62 15.88 18 7.5 26.38l2.12 2.12L18 20.12l8.38 8.38 2.12-2.12L20.12 18z" /> A valid svg path to show as icon.
animationDuration number 500 Animation duration in milliseconds.
container object You can specify a container prop which should be of type Element. The portal will be rendered inside that element. The default behavior will create a div node and render it at the at the end of document.body.

License

MIT © Léo Pradel

react-responsive-modal's People

Contributors

pradel avatar renovate-bot avatar choznerol avatar peterlazzarino avatar bmv437 avatar amertak avatar russellmorgan avatar aleemb avatar renovate[bot] avatar

Watchers

James Cloos avatar Nuruzzaman Khan Nabwab 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.