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

@gustavolmo/react-window-manager

v0.3.1

Published

---

Downloads

716

Readme

React Window Manager


Installation

Install the package

pnpm add @gustavolmo/react-window-manager
# or
npm install @gustavolmo/react-window-manager
# or
yarn add @gustavolmo/react-window-manager

Requirements

You must have:

  • React 18+ (or 19)
  • React DOM
  • Zustand

Install it with

pnpm add react react-dom zustand

Styling

This library ships with its own compiled CSS.

Import the stylesheet once at your application root:

import "@gustavolmo/react-window-manager/index.css"

The styling properties of compoents accept tailwind or regular css classes


Overview

A lightweight desktop-style window manager built with:

  • React
  • Zustand (isolated state per window)
  • A shared WorkspaceLayout
  • Independent WindowLayout instances
  • External WindowButton controllers

Each window instance is fully isolated, draggable, dockable, and externally controllable via its own store.


1. Create a Window Store

Initialize a window instance early (module scope recommended):

const myWindow = createWindowStore('window-my-id')
  • The ID must be unique.
  • The return value is a standard Zustand hook.
  • Each window is automatically registered internally.

You can create multiple windows:

const firstWindow = createWindowStore('window-first')
const secondWindow = createWindowStore('window-second')

2. Wrap Everything in WorkspaceLayout

All windows must be rendered inside a shared workspace:

<WorkspaceLayout>
  {/* WindowLayout components */}
</WorkspaceLayout>

The workspace acts as:

  • The rendering surface
  • The stacking context
  • The coordinate system for all windows

3. Render a Window

Use WindowLayout and pass:

  • useWindowStore → the store instance
  • windowName → title (string or ReactNode)
  • defaultDock → initial docking behavior (optional)
<WindowLayout
  useWindowStore={myWindow}
  windowName="My Window"
  defaultDock="right"
>
  <div>Any React content</div>
</WindowLayout>

Supported docking modes:

  • "left"
  • "right"
  • "full"

Responsive docking can be computed:

defaultDock={window.innerWidth < 800 ? 'full' : 'left'}

4. Control a Window with WindowButton

Place a control button anywhere in your UI:

<WindowButton useWindowStore={myWindow}>
  <p>Open Window</p>
</WindowButton>
  • Multiple buttons can control the same window.
  • Buttons are fully decoupled from layout.
  • No prop drilling is required.

5. Access Window State

Since the store is a standard Zustand hook, you can read window state directly:

const { isDragging, isResizing } = myWindow()

Example use case:

className={
  isDragging || isResizing
    ? 'pointer-events-none'
    : 'pointer-events-auto'
}

This is useful when embedding iframes or other complex interactive content.


6. Access via Registry (Optional)

Windows are also registered globally by ID:

const { isOpen } = windowRegistry['window-my-id']()

This is useful when you do not have direct access to the original store reference.


Architecture Summary

  • createWindowStore(id) → creates isolated window state
  • WorkspaceLayout → shared window surface
  • WindowLayout → draggable and dockable container
  • WindowButton → external controller
  • Zustand → reactive state management

Design Principles

  • Fully decoupled window instances
  • No global prop chains
  • Arbitrary React content support (apps, iframes, components)
  • Independent lifecycle per window
  • Scalable to many concurrent windows

This enables building browser-based desktop-style interfaces with minimal setup and clean separation of concerns.