JSPM

@oragie/react-modal-lib

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q20406F
  • License MIT

A customizable and accessible modal component for React.

Package Exports

  • @oragie/react-modal-lib

Readme

๐Ÿงฉ react-modal-lib

A simple, reusable, and accessible modal component for React.

Inspired by jquery-modal, rebuilt for the modern React ecosystem.


๐Ÿ“ฆ Installation

npm install react-modal-lib

๐Ÿš€ Usage

import React, { useState } from "react";
import { Modal } from "react-modal-lib";

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

  return (
    <>
      <button onClick={() => setIsOpen(true)}>Open modal</button>

      <Modal isOpen={isOpen} onClose={() => setIsOpen(false)}>
        <h2>Hello ๐Ÿ‘‹</h2>
        <p>This is the content of the modal.</p>
      </Modal>
    </>
  );
}

๐Ÿ›  Props

'

Prop Type Default Description
isOpen boolean โ€” Controls whether the modal is open
onClose () => void โ€” Called when the modal should close
children ReactNode โ€” Modal content
closeOnOverlayClick boolean true Close the modal when clicking the overlay
closeOnEscape boolean true Close the modal when pressing Escape
showCloseButton boolean true Show the "ร—" close button

'


๐ŸŽจ Styling

The modal uses its own internal Modal.css, but you can override styles via classnames:

.modal-overlay {
  ...;
}
.modal-content {
  ...;
}
.modal-close {
  ...;
}

Make sure to import the CSS:

import "react-modal-lib/dist/style.css";

Or include it via bundler (already included if you use Vite).


๐Ÿงช Local Testing

To test this library locally:

# In the library folder
npm run build
npm link

# In your React app
npm link react-modal-lib

๐Ÿ“„ License

MIT โ€” free to use and modify.