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

shadcn-modal-manager

v1.0.0

Published

Lightweight React modal manager with promise-based API. Supports Shadcn UI, Radix UI and Base UI.

Downloads

1,060

Readme

shadcn-modal-manager

A lightweight, type-safe, and animation-aware modal management library for React.

Tests License: MIT

Features

  • 🚀 Promise-based API - open() returns promises for afterOpened() and afterClosed().
  • 🛡️ Type-safe - Full TypeScript support with generics for modal data and results.
  • ✨ Animation-aware - Automatically waits for enter/exit animations/transitions before cleanup.
  • 🔌 Pre-built Adapters - Seamless integration with Shadcn UI, Radix UI, and Base UI.
  • 📦 Lightweight - Zero dependencies beyond React.
  • 🧠 Flexible - Manage modals via programmatic API or declarative JSX.

Installation

npm install shadcn-modal-manager

Quick Start

1. Wrap your app with the Provider

import { ModalProvider } from "shadcn-modal-manager";

function Root() {
  return (
    <ModalProvider>
      <App />
    </ModalProvider>
  );
}

2. Define a modal

Use pre-built adapters to bridge your UI library with Shadcn Modal Manager.

import { ModalManager, useModal, shadcnUiDialog, shadcnUiDialogContent } from "shadcn-modal-manager";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";

const MyModal = ModalManager.create(({ title }: { title: string }) => {
  const modal = useModal();

  return (
    <Dialog {...shadcnUiDialog(modal)}>
      <DialogContent {...shadcnUiDialogContent(modal)}>
        <DialogHeader>
          <DialogTitle>{title}</DialogTitle>
        </DialogHeader>
        <p>This is a managed modal!</p>
        <button onClick={() => modal.close("success")}>Close with Result</button>
      </DialogContent>
    </Dialog>
  );
});

3. Open the modal

// 1. Programmatic Usage (e.g., in an event handler)
const openConfirmModal = async () => {
  const modalRef = ModalManager.open(MyModal, {
    data: { title: "Are you sure?" }
  });

  const result = await modalRef.afterClosed();

  if (result === "success") {
    // Handle success
  }
};

// 2. Declarative Usage (via JSX)
import { ModalDefinition } from "shadcn-modal-manager";

function MyPage() {
  return (
    <>
      {/* Registers the modal for later use by its ID */}
      <ModalDefinition id="optional-id" component={MyModal} />
      <button onClick={() => ModalManager.open("optional-id")}>Open by ID</button>
    </>
  );
}

Common Patterns

1. Returning Results

The open() function is generically typed to support results.

const openConfirm = async () => {
  const modalRef = ModalManager.open<boolean>(MyModal);
  const result = await modalRef.afterClosed();

  if (result) {
    console.log("User confirmed!");
  }
};

2. Lifecycle Hooks

Wait for the modal to be fully opened or perform actions before it closes.

const ref = ModalManager.open(MyModal);

ref.afterOpened().then(() => {
  console.log("Modal is now fully visible and animations are done.");
});

const result = await ref.afterClosed();

3. Closing All Modals

Useful for navigation changes or resetting application state.

// Closes all modals and waits for their exit animations
await ModalManager.closeAll();

Supported Libraries (Adapters)

We provide pre-built adapters to make integration seamless:

Shadcn UI

import { shadcnUiDialog, shadcnUiDialogContent, shadcnUiDrawer } from "shadcn-modal-manager";

Adapters: shadcnUiDialog, shadcnUiDialogContent, shadcnUiAlertDialog, shadcnUiSheet, shadcnUiDrawer, shadcnUiPopover.

Radix UI

import { radixUiDialog, radixUiDialogContent, radixUiPopover } from "shadcn-modal-manager";

Adapters: radixUiDialog, radixUiDialogContent, radixUiAlertDialog, radixUiAlertDialogContent, radixUiPopover, radixUiSheet.

Base UI

import { baseUiDialog, baseUiPopover } from "shadcn-modal-manager";

Adapters: baseUiDialog, baseUiDialogPopup, baseUiDialogPortal, baseUiAlertDialog, baseUiAlertDialogPopup, baseUiPopover, baseUiPopoverPopup, baseUiPopoverPortal, baseUiSheet.

Documentation

For full documentation, including advanced usage, custom adapters, and API reference, visit shadcn-modal-manager.achromatic.dev.

License

MIT


Maintained by Achromatic