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

@uppercut-labs/react-modal-dialog

v0.1.0

Published

Accessible React modal dialog with focus trap, scroll lock, focus restore and Escape or backdrop close, unstyled by default.

Readme

@uppercut-labs/react-modal-dialog

An accessible modal dialog for React. It traps focus, locks page scroll, restores focus to the element that opened it, closes on Escape or a press on the backdrop, and labels the dialog with its title. It ships without styling; an optional small stylesheet is included.

npm install @uppercut-labs/react-modal-dialog
import { useState } from 'react';
import { Modal, useRequestClose } from '@uppercut-labs/react-modal-dialog';
import '@uppercut-labs/react-modal-dialog/styles.css'; // optional

function CancelButton() {
  const close = useRequestClose();
  return <button onClick={close}>Cancel</button>;
}

export function Example() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <button onClick={() => setOpen(true)}>Rename</button>
      <Modal
        open={open}
        title="Rename project"
        onClose={() => setOpen(false)}
        actions={
          <>
            <CancelButton />
            <button form="rename-form">Save</button>
          </>
        }
      >
        <form id="rename-form">
          <input name="name" aria-label="Name" />
        </form>
      </Modal>
    </>
  );
}

The dialog renders div.rmd-backdrop > div.rmd-dialog[role=dialog] with .rmd-header, .rmd-title, .rmd-close, .rmd-body and .rmd-actions inside. Add your own classes with the className props, or style the rmd-* classes directly.

Modal props

| Prop | Default | Meaning | | --- | --- | --- | | title | required | Heading; names the dialog | | onClose | required | Called when the user asks to close. You decide whether to unmount | | open | true | Renders nothing when false | | actions | none | Footer content | | closeOnEscape | true | Escape asks to close | | closeOnBackdrop | true | A press on the backdrop asks to close | | trapFocus | true | Tab and Shift+Tab stay inside the dialog | | lockScroll | true | Page behind cannot scroll; nested modals share one lock | | restoreFocus | true | Focus returns to the previously focused element | | initialFocus | see below | CSS selector inside the dialog, or a ref | | closeDisabled | false | Ignore all close requests, for example while saving | | dirty | false | Browser warns before reload or tab close | | beforeClose | none | Return false to veto a close request | | role | dialog | Or alertdialog | | describedBy | none | Id of a describing element | | showCloseButton | true | Close button in the header | | closeLabel | Close dialog | Accessible name of the close button | | portal | true | Render into document.body | | className, backdropClassName, headerClassName, titleClassName, bodyClassName, actionsClassName, closeButtonClassName | none | Extra classes |

Initial focus goes to the selector or ref in initialFocus, else an element with data-autofocus, else the first tabbable element in the body, else the close button, else the dialog.

Other exports

| Export | Meaning | | --- | --- | | useRequestClose() | Inside a Modal, returns a function that closes it by the same rules as Escape, including closeDisabled and beforeClose | | getTabbableElements(root) | Elements Tab can reach inside root: skips disabled, hidden and tabindex="-1" elements, and keeps one radio per group | | lockScroll() | Locks page scroll and returns a release function |

License

MIT