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-floating-modals

v1.0.3

Published

Drag-to-move modal & window library for React with~ zero dependencies.

Readme

React Floating Modals

This library was created as a small and reusable module to streamline usually tedious and long process of creating floating modals.

key features:

  • zero-dependency (except React itself of course) window library for React 18+.
  • Pointer-Events drag – smooth on mouse, touch & pen.
  • Headless styling – bring your own CSS or Tailwind; nothing is hard-coded.
  • Window manager – one context handles z-index and cleanup.
  • Tiny bundle – no external libraries, tree-shakeable.
  • 100 % TypeScript – autocompletion for every prop & hook.

Installation

npm i react-floating-modals          # or pnpm add / yarn add

Peer dependencies: react >= 18, react-dom >= 18.


Quick start

import {
  WindowManagerProvider,
  useWindowManager,
  FloatingModal
} from 'react-floating-modals';

function App() {
  return (
    <WindowManagerProvider>
      <LauncherButton />
    </WindowManagerProvider>
  );
}

function LauncherButton() {
  const wm = useWindowManager();

  return (
    <button onClick={() => wm.spawn(<MyWindow />)}>
      Open window
    </button>
  );
}

function MyWindow({ windowId }: { windowId?: number }) {
  const wm = useWindowManager();

  return (
    <div className="my-window">
      <header data-drag-handle>
        Drag me!
        <button onClick={() => windowId !== undefined && wm.close(windowId)}>
          ×
        </button>
      </header>
      <main>Any content…</main>
    </div>
  );
}
  1. Wrap your app (or a subtree) with <WindowManagerProvider>.
  2. Call wm.spawn(<YourComponent />) to open a new window.
  3. Inside the window, read windowId and call wm.close(windowId) to dismiss it.
  4. Add data-drag-handle to any element (or pass handleSelector prop) to make it draggable.

API reference

<FloatingModal />

| Prop | Type | Default | Description | |------|------|---------|-------------| | initialX | number \| 'center' | 'center' | Starting left (px) or center. | | initialY | number \| 'center' | 'center' | Starting top (px) or center. | | handleSelector | string | '[data-drag-handle]' | CSS selector for the drag handle, searched relative to the modal root. | | onDrag | (coords ⇒ void) | — | Callback on every move { x, y }. | | …div props | — | — | Regular <div> attributes (style, className, etc.). |

Imperative handle

const ref = useRef<FloatingModalHandle>(null);

ref.current?.resetPosition(0, 0);      // snap to top-left
ref.current?.resetPosition('center');  // recenter

<WindowManagerProvider />

Provides a store for all windows.

const wm = useWindowManager();

const id = wm.spawn(<Window />);   // open
// wm.spawn has second optional argument - singleTone=true, if enabled, allows to create only single active instance of the same modal 
wm.focus(id);                      // bring to front
wm.close(id);                      // close
wm.closeAll()                      // close all open windows

Styling

react-floating-modals ships no CSS by default—it’s headless.
Assign your own classes or inline styles. A minimal Tailwind look:

<div className="w-80 bg-white rounded shadow-lg">
  <header
    data-drag-handle
    className="bg-indigo-600 text-white px-4 py-2 rounded-t cursor-move flex justify-between"
  >
    …

License

MIT