New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@slithy/modal-core

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slithy/modal-core

Core modal state management for @slithy/modal-kit.

latest
npmnpm
Version
0.1.3
Version published
Maintainers
1
Created
Source

@slithy/modal-core

The modal store. No React components, no animation, no UI.

modal-core owns the state machine and is the source of truth for which modals are open. All other modal packages depend on it. Consuming apps interact with it directly to open and close modals.

Installation

pnpm add @slithy/modal-core

Opening and Closing

All store methods are available via useModalStore.getState() for use outside React, or via the hook for reactive access.

import { useModalStore } from '@slithy/modal-core'

// Open a modal — pass any ReactNode
const id = useModalStore.getState().openModal(<MyModal />, {
  triggerEvent: event,   // enables keyboard-triggered focus return on close
})

// Close
useModalStore.getState().closeModal()        // topmost modal
useModalStore.getState().closeModal(id)      // specific modal
useModalStore.getState().closeAllModals()    // all modals

openModal options

OptionTypeDescription
idstringStable ID; reuses the slot if already open
triggerEventModalTriggerEventEnables focus return to the triggering element
triggerElementElementExplicit element to focus on close
skipAnimationbooleanSkip enter/leave animation
closeModalsstring[]Close specific modals before opening this one

Reactive Access

import { useModalStore } from '@slithy/modal-core'

// Re-renders when modals change
const modals = useModalStore(s => s.modals)
const isAnyOpen = useModalStore(s => s.modals.length > 0)

// One-time read or in event handlers
const isOpen = useModalStore.getState().modalIsOpen()
const isOpen = useModalStore.getState().modalIsOpen(id)

Types

type ModalState = 'opening' | 'open' | 'closing' | 'closed'

type ModalElement = {
  id: string
  modal: React.ReactNode
  skipAnimation?: boolean
  state: ModalState
  triggerElement?: HTMLElement | null
}

Exports

ExportDescription
useModalStoreZustand-style store hook
ModalStoreStore type
ModalState'opening' | 'open' | 'closing' | 'closed'
ModalElementShape of a registered modal
ModalTriggerEventUnion of synthetic and native event types

FAQs

Package last updated on 03 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts