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

@delaroche/hrnet-modal

v1.3.0

Published

Reusable customizable modal component for React

Downloads

74

Readme

HRnet Modal

A reusable and customizable React modal component for alerts, confirmation dialogs, forms, and custom content.

The component supports desktop and mobile modals, mobile bottom sheets, swipe-to-close gestures, custom icons, styling props, and accessibility-friendly behavior.


Features

  • Reusable React modal component
  • Desktop centered modal
  • Mobile bottom sheet mode
  • selection of bottom sheet mode or modal mode for mobile
  • Optional iOS-style drag handle
  • Swipe down to close on mobile bottom sheet
  • Close on overlay click
  • Close with Escape key
  • Optional close icon
  • Optional cancel and confirm buttons
  • Custom icons for action buttons
  • Custom content with children
  • Custom colors, width, border radius, font, and shadow
  • Scroll lock while modal is open
  • Accessibility support

Installation

npm install @delaroche/hrnet-modal

Import

import HRnet_modal from "@delaroche/hrnet-modal";
import "@delaroche/hrnet-modal/style.css";

Basic Usage

import { useState } from "react";
import HRnet_modal from "@delaroche/hrnet-modal";
import "@delaroche/hrnet-modal/style.css";
import { Trash2, Check } from "lucide-react";

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

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

      <HRnet_modal
        isOpen={isOpen}
        onClose={() => setIsOpen(false)}
        title="Delete employee"
        message="Are you sure?"
        showCancelButton={true}
        cancelIcon={<Check size={16} />}
        showConfirmButton={true}
        confirmIcon={<Trash2 size={16} />}
        cancelText="Cancel"
        confirmText="Delete"
        onCancel={() => setIsOpen(false)}
        onConfirm={() => alert("Deleted")}
      />
    </>
  );
}

export default App;

Confirmation Example

<HRnet_modal
  isOpen={isOpen}
  title="Delete Employee"
  message="Are you sure?"
  onClose={() => setIsOpen(false)}
  onCancel={() => setIsOpen(false)}
  onConfirm={handleDelete}
  showCancelButton
  showConfirmButton
  cancelText="Cancel"
  confirmText="Delete"
  confirmButtonColor="#dc2626"
/>

Mobile Modes

Bottom Sheet (default)

<HRnet_modal
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  mobileMode="bottom-sheet"
/>

Centered Modal

<HRnet_modal
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  mobileMode="modal"
/>

When using mobileMode="modal", the drag handle is automatically hidden.


Overlay Position

Fixed (default)

Covers the full screen.

overlayPosition = "fixed";

Absolute

Useful if you only want to cover a parent container such as <main>.

overlayPosition = "absolute";

Parent element must have:

.main {
  position: relative;
}

Custom Icons

import { X, Trash2 } from "lucide-react";

<HRnet_modal
  isOpen={isOpen}
  showCloseIcon
  closeIcon={<X size={22} />}
  confirmIcon={<Trash2 size={16} />}
/>;

Custom Content

<HRnet_modal
  isOpen={isOpen}
  title="Custom Form"
  onClose={() => setIsOpen(false)}
>
  <form>
    <input type="text" placeholder="Your name" />
    <button type="submit">Save</button>
  </form>
</HRnet_modal>

Props

| Prop | Type | Default | Description | | ---------------------- | --------------- | ------------ | --------------------------- | | isOpen | boolean | required | Controls modal visibility | | onClose | function | required | Close callback | | title | string | Modal title | Title text | | message | string | "" | Optional message | | children | node | null | Custom content | | showCloseIcon | boolean | false | Show close button | | showCancelButton | boolean | false | Show cancel button | | showConfirmButton | boolean | false | Show confirm button | | closeIcon | node | X | Custom close Icon | | cancelIcon | node | null | Icon before cancel label | | confirmIcon | node | null | Icon before confirm label | | onCancel | function | optional | Cancel callback | | onConfirm | function | optional | Confirm callback | | cancelText | string | Cancel | Cancel button text | | confirmText | string | Confirm | Confirm button text | | mobileMode | string | bottom-sheet | modal / bottom-sheet | | overlayPosition | string | fixed | fixed / absolute | | width | string / number | 520px | Modal width | | maxHeight | string / number | 85vh | Max height | | borderRadius | string / number | 20px | Radius | | backgroundColor | string | #ffffff | Background | | textColor | string | #111827 | Text color | | titleColor | string | #111827 | Title color | | overlayColor | string | rgba(...) | Overlay color | | fontFamily | string | inherit | Font family | | className | string | "" | Custom modal class | | overlayClassName | string | "" | Custom overlay class | | bodyClassName | string | "" | Custom body class | | confirmButtonClassName | string | "" | Custom confirm button class | | cancelButtonClassName | string | "" | Custom cancel button class | | closeButtonClassName | string | "" | Custom close button class |


Accessibility

Includes:

  • role="dialog"
  • aria-modal="true"
  • aria-labelledby
  • aria-describedby
  • Escape key closing
  • Automatic focus on opening

License

MIT

Changelog

See full release history here:

CHANGELOG.md