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

@slithy/layers

v0.1.1

Published

Layer and z-index management for React UIs.

Downloads

158

Readme

@slithy/layers

Layer and z-index management for React UIs. Tracks a stack of mounted layers and determines which is "active" (highest priority). Useful for managing focus, keyboard interactions, and visual stacking of overlaid components like modals and drawers.

Installation

npm install @slithy/layers

Peer dependencies: react@^17 || ^18 || ^19


LayerProvider

Wraps a component to register it in the global layer stack. On mount, the layer is added to the stack; on unmount, it is removed.

import { LayerProvider, LayerStackPriority } from '@slithy/layers'

<LayerProvider id="my-modal" zIndex={LayerStackPriority.Modal}>
  <MyModal />
</LayerProvider>

Props:

| Prop | Type | Default | Description | |---|---|---|---| | id | string | auto-generated | Unique identifier for this layer | | zIndex | number | 0 | Priority in the stack — higher wins | | isActive | boolean | true | If false, layer is not registered in the stack | | children | ReactNode | — | |


useLayerState

Hook to read state from the nearest LayerProvider. Must be called within a LayerProvider.

// Selector form — returns selected value, re-renders only on change
const layerIsActive = useLayerState(s => s.layerIsActive)

// No-arg form — returns full store object
const { getState, setState } = useLayerState()

Store shape (LayerStore):

type LayerStore = {
  layerID: string
  layerIsActive: boolean  // true when this layer has the highest priority
  zIndex: number
}

useLayerStackStore

Direct access to the global layer stack store. Useful for reading or subscribing to stack-wide state outside of a LayerProvider.

import { useLayerStackStore } from '@slithy/layers'

const { activeLayerId, layers } = useLayerStackStore.getState()

const unsubscribe = useLayerStackStore.subscribe(() => {
  const { activeLayerId } = useLayerStackStore.getState()
})

createLayerPriorities

Factory for defining a custom set of layer priorities. Returns a frozen readonly object.

import { createLayerPriorities } from '@slithy/layers'

const MyPriorities = createLayerPriorities({
  Base: 0,
  Overlay: 5,
  Toast: 10,
})

<LayerProvider zIndex={MyPriorities.Toast}>
  <ToastStack />
</LayerProvider>

LayerStackPriority

The built-in default priority set, defined with createLayerPriorities:

const LayerStackPriority = createLayerPriorities({
  Base: 0,
  Modal: 1,
  Toasts: 2,
})

MockLayerProvider

A test utility that provides a mock layer context with hardcoded values. Use this to render components that depend on LayerProvider without needing a real stack.

import { MockLayerProvider } from '@slithy/layers'

render(
  <MockLayerProvider>
    <ComponentUnderTest />
  </MockLayerProvider>
)