npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2019 – Ryan Hefner

react-responsive-modal

v4.0.1

Published

A simple responsive and accessible react modal

Downloads

94,765

Maintainers

leopradelleopradel

Readme

react-responsive-modal

npm version npm downloads per month codecov dependencies Status

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

  • Focus trap inside the modal.
  • Centered modals.
  • Scrolling modals.
  • Multiple modals.
  • Easily customizable via props.

Documentation

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

NameTypeDefaultDescription
closeOnEscbooltrueIs the modal closable when user press esc key.
closeOnOverlayClickbooltrueIs the modal closable when user click on overlay.
onEnteredfuncnullCallback fired when the Modal is open and the animation is finished.
onExitedfuncnullCallback fired when the Modal has exited and the animation is finished.
onClose*funcCallback fired when the Modal is requested to be closed by a click on the overlay or when user press esc key.
onEscKeyDownfuncnullCallback fired when the escape key is pressed.
onOverlayClickfuncnullCallback fired when the overlay is clicked.
open*boolControl if the modal is open or not.
classNamesobjectAn 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'
stylesobjectAn object containing the styles objects to style the modal, can have properties 'overlay', 'modal', 'closeButton', 'closeIcon'.
childrennodenullThe content of the modal.
centerboolfalseShould the dialog be centered.
showCloseIconbooltrueShow the close icon.
closeIconSizenumber28Close icon size.
closeIconSvgPathnode<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.
animationDurationnumber500Animation duration in milliseconds.
containerobjectYou 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.
blockScrollbooltrueWhether to block scrolling when dialog is open
focusTrappedboolfalseWhen the modal is open, trap focus within it
focusTrapOptionsobjectOptions to be passed to the focus trap, details available at https://github.com/davidtheclark/focus-trap#focustrap--createfocustrapelement-createoptions
overlayIdstringnullid attribute for overlay
modalIdstringnullid attribute for modal
closeIconIdstringnullid attribute for close icon
rolestring'dialog'ARIA role for modal
ariaLabelledbystringARIA label for modal
ariaDescribedbystringARIA description for modal

License

MIT © Léo Pradel