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

jackvpt-custom-modal

v1.0.41

Published

Custom Modal

Readme

Modal Component

A customizable and accessible modal (dialog) component built with React, supporting dynamic content, smooth CSS transitions, and flexible styling.

✨ Features

  • Smooth CSS-based open/close animations
  • Escape key support to close the modal
  • Click outside to close
  • Customizable header and backdrop colors
  • Supports both text and custom HTML/JSX content
  • Optional shadow around the modal
  • Fully typed with PropTypes
  • Lightweight and dependency-free

🔧 Prerequisites

Before using this component, make sure your project meets the following requirements:

✅ Uses React version 17, 18, or 19

✅ Has ReactDOM installed

✅ Includes PropTypes (already included in the package if you're using a bundler)

✅ Supports CSS or SCSS handling (via Vite, Webpack, or CRA)

✅ Accepts peer dependencies (ensure that react and react-dom are not duplicated in node_modules)


📦 Installation

Clone or copy the Modal component into your project or use npm install jackvpt-custom-modal.


🚀 Usage

import Modal from "./Modal"

function App() {
  const [isModalOpen, setModalOpen] = React.useState(false)

  const handleOpen = () => setModalOpen(true)
  const handleClose = () => setModalOpen(false)

  return (
    <>
      <button onClick={handleOpen}>Open Modal</button>
      <Modal
        isOpen={isModalOpen}
        onClose={handleClose}
        modalElements={{
          title: "Success",
          subtitle: "Employee created",
          text: "Employee John Doe has been added.",
          htmlElement: <p>Additional custom content here.</p>,
          closeButtonText: "Close Modal",
        }}
        modalOptions={{
          headerBackgroundColor: "#4caf50",
          headerTextColor: "#fff",
          backdropColor: "rgba(0, 0, 0, 0.5)",
          shadowed: true,
        }}
      />
    </>
  )
}

⚙️ Props

Required Props

| Prop | Type | Description | |-----------------|-------------|-------------------------------------| | isOpen | boolean | Controls the visibility of the modal. | | onClose | function | Function to call when modal should close. | | modalElements | object | Defines the content displayed in the modal. |

Optional Props

| Prop | Type | Description | |-------------------|-----------|-------------------------------------| | modalElements.title | string | Modal title text. | | modalElements.subtitle | string | Modal subtitle text. | | modalElements.text | string | Optional plain text content. | | modalElements.htmlElement | ReactNode | Optional JSX/HTML to render. | | modalElements.closeButtonText | string | Text for the close button (default: "Close"). | | modalOptions.headerBackgroundColor | string | Header background color. | | modalOptions.headerTextColor | string | Header text color. | | modalOptions.backdropColor | string | Backdrop background color (default: rgba(0, 0, 0, 0.7)). | | modalOptions.shadowed | boolean | Enables/disables shadow around the modal (default: true). |


🎨 Styling

The component uses CSS transitions defined in the accompanying SCSS file (Modal.scss).

Main classes:

  • .modal-backdrop
  • .modal-content
  • .modal-header
  • .modal-close
  • .modal-subtitle
  • .modal-text
  • .modal-htmlElement
  • .modal-button-close
  • .shadowed

You can easily override or extend the styles based on your project needs.


🛡 Accessibility

  • Keyboard accessible (press Escape key to close)
  • Clickable backdrop to close the modal
  • Semantic and accessible HTML structure

📄 License

This component is free to use and modify under the MIT License.


📝 Notes

  • The modal appears/disappears using CSS transitions on opacity and scale.
  • There are no external dependencies needed.
  • Works out of the box in any React project.