1.0.13 • Published 1 year ago

react-web-modal v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

React Web Modal

A simple react modal component with no dependencies that is easy to use and customize. Of course it comes with responsive styles out of the box.

Installation

npm install react-web-modal

Demo

Open the demo in CodeSandbox

Usage

import React from "react";
import { Modal } from "react-web-modal";

function App() {
  const [isVisible, setIsVisible] = React.useState(false);

  render() {
    return (
      <div>
        <button onClick={() => setIsVisible(true)}>Open Modal</button>
        <Modal
          visible={isVisible}
          onClose={() => console.log("Modal closed")}
        >
          <div>
            <h1>Simple Modal</h1>
            <p>Modal content</p>
            <a onClick={() => setIsVisible(false)}>Close</a>
          </div>
        </Modal>
      </div>
    );
  }
}

Props

PropDescriptionTypeDefault ValueRequired
isVisibleControls the visibility of the modalbooleanYes
setIsVisibleCallback function to set the visibility of the modalfunctionYes
headerHeader content of the modalReact.ReactNodeNo
childrenContent of the modalReact.ReactNodeNo
onOpenCallback function triggered when the modal is openedfunction() => setIsVisible(true)No
lockScrollControls whether to lock scrolling on the background when modal is openbooleantrueNo
onCloseCallback function triggered when the modal is closedfunction() => setIsVisible(false)No
maxWidthMaximum width of the modalstring"600px"No
maxHeightMaximum height of the children modalstring"85vh"No
closeOnBgClickControls whether to close the modal when clicking on the backgroundbooleantrueNo
closeOnEscapeControls whether to close the modal when pressing the escape keybooleantrueNo
animationDurationDuration of the modal animation in millisecondsnumber400No
backgroundBackground color of the modal backgroundstring"rgba(0,0,0,0.5)"No
modalBackgroundBackground color of the modalstring"white"No

License

MIT

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago