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 🙏

© 2026 – Pkg Stats / Ryan Hefner

angel1979-react-simple-modal

v1.0.5

Published

A simple and flexible modal component for React applications, providing high accessibility and easy integration.

Readme

Modal Component in React

"A simple, yet flexible, modal component for React. Easy to use and integrate into any React project. Fully accessible and customizable."

Table of Contents

Using ReactDOM.createPortal

Our modal component leverages ReactDOM.createPortal to render the modal content. This React feature enables rendering children into a DOM node that exists outside the parent component's DOM hierarchy. This is particularly useful for modal windows, which are typically rendered at the application's root rather than as a direct child of the triggering component. Thanks to ReactDOM.createPortal, our modal can appear above the rest of the application while maintaining the same properties and behaviors as any other React component.

For more information, click here : https://react.dev/reference/react-dom/createPortal

How to install the Modal

Before installing the Modal component, ensure you have a div element with an id of modal-root in your HTML file. This is where the modal content will be rendered.

<!-- in your HTML file  -->
<body>
  ...
  <div id="modal-root"></div>
</body>

Next, you can install the Modal component using npm:

npm install angel1979-react-simple-modal

Usage

First, import the Modal component from the library:

import Modal from "angel1979-react-simple-modal";

Then, use the Modal component within your React component. Here's an example:

import React, { useState } from "react";
import Modal from "angel1979/react-simple-modal";

function App() {
  const [isOpen, setIsOpen] = useState(false);

  const openModal = () => setIsOpen(true);
  const closeModal = () => setIsOpen(false);

  return (
    <div>
      <button onClick={openModal}>Open Modal</button>

      <Modal
        isOpen={isOpen}
        onClose={closeModal}
        title="Hello, world!"
        buttonLabel="Close"
        onButtonClick={closeModal}
      >
        <p>Welcome to my modal!</p>
      </Modal>
    </div>
  );
}

export default App;

Advanced Usage: Using Modal with a Form

In this example, we're using the modal within a form. When the form is submitted, the modal opens. Here's an example:

First, initialize the isOpen state for the modal:

const [isModalOpen, setIsModalOpen] = useState(false);

In your form submission handler function, you can open the modal based on certain conditions:

const handleSubmit = (e) => {
  e.preventDefault();

  setIsModalOpen(true);
};

Then, define a function to close the modal:

const handleModalClose = () => {
  setIsModalOpen(false);
};

Finally, you can use the Modal component within your form and pass these functions as props:

<Modal
  isOpen={isModalOpen}
  onClose={handleModalClose}
  title="Action completed!"
  buttonLabel="Close"
  onButtonClick={handleModalClose}
/>

Properties

What props can you add ?

Modal accepts the following props:

isOpen (boolean, Required): The open state of the modal. If true, the modal is open. If false, the modal is closed.

onClose (function, Required): Function to call when the modal is requested to close. This function should set isOpen to false.

title (string, Optional): The title of the modal. Displayed at the top of the modal.

buttonLabel (string, Optional): The label of the close button. Displayed in the button that closes the modal.

onButtonClick (function, Optional): Function to call when the button inside the modal is clicked.

Peer Dependencies

This component has peer dependencies with React and ReactDOM:

"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}

These versions are the minimum required versions. Ensure these dependencies are met in your project.
If you have not already installed these dependencies, you can do so by using npm or yarn:

With npm:

npm install react react-dom

With yarn:

yarn add react react-dom

License

MIT