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

react-lite-modal

v1.0.2

Published

lite and bare modal for react

Downloads

4

Readme

React Lite Modal

A lightweight, accessible, and customizable modal package for React. This package provides a headless modal container with an overlay and focus-trapping behavior. It’s designed to be flexible, allowing integrators to control the modal content while ensuring full accessibility.

Features

  • Lightweight and minimalistic.
  • Customizable overlay and content area.
  • Focus trapping to ensure accessibility.
  • Close modal on overlay click (optional).
  • ARIA roles for screen reader accessibility.

Installation

npm

npm install react-lite-modal

yarn

yarn add react-lite-modal

How to Render the Modal

Our modal component requires a div with the id="modal-root" in your HTML. This is where the modal will be appended to the DOM. By rendering it outside the normal DOM flow, it helps ensure that the modal's overlay and content are displayed above other content without being affected by the parent component's z-index or overflow properties.

Step 1: Add the Modal Root to public/index.html

In your public/index.html file, add the following div just inside the <body> tag:

<body>
    <div id="root"></div>
    <div id="modal-root"></div>
</body>

Usage

Here’s a basic example of how to use the modal component:

import React, { useState } from 'react';
import { ModalOverlay } from 'react-lite-modal';

const App = () => {
  const [isModalOpen, setModalOpen] = useState(false);

  const handleClose = () => setModalOpen(false);

  return (
    <>
      <button onClick={() => setModalOpen(true)}>Open Modal</button>

      {isModalOpen && (
        <ModalOverlay
          closeOnOverlayClicked={true}
          isActive={isModalOpen}
          onClose={handleClose}
        >
          <div>
            <h2>Modal Title</h2>
            <p>This is the modal content.</p>
            <button onClick={handleClose}>Close</button>
          </div>
        </ModalOverlay>
      )}
    </>
  );
};

WCAG Accessibility Compliance

This package follows WCAG 2.1 accessibility guidelines to ensure an inclusive experience for all users:

  • Focus Management: Automatically traps the focus within the modal to prevent users from interacting with the background content. The first focusable element is automatically focused when the modal opens.
  • Keyboard Navigation: Ensures that users can navigate through the modal content using the Tab and Shift+Tab keys.
  • ARIA Roles:
  • role="dialog": The modal is announced as a dialog by screen readers.
  • aria-modal="true": Indicates that the modal is a modal window, preventing users from interacting with background content.
  • aria-labelledby and aria-describedby: These attributes should be used to reference the modal’s title and description for screen reader users.

Props

| Prop | Type | Default Value | Description | | ----------------------- | ------------------- | ------------- | ------------------------------------------------------------- | | isOpen | boolean | false | Controls whether the modal is open or closed. | | closeOnOverlayClicked | boolean | true | Determines if the modal closes when the overlay is clicked. | | onClose | () => void | undefined | Callback function to close the modal. |

Note: props for HTML div element attributes are included