Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@stackmeister/react-overlay

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackmeister/react-overlay

@stackmeister/react-overlay ===============================

latest
Source
npmnpm
Version
0.1.7
Version published
Weekly downloads
5
-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

@stackmeister/react-overlay

Utility for easily overlaying elements over the whole app in React.

It helps elements deep inside the DOM to break out of it and avoid z-index fuckery when creating modals, dialogs, tooltips, tutorial markers etc.

Create modals and tooltips from wherever you are in your components!

It is using React Portals, some DOM-manipulation, but no CSS. Positioning etc. is up to your app. The OverlayPortal will just help you to break out of the DOM.

Install

// Yarn
yarn add @stackmeister/react-overlay

// NPM
npm i @stackmeister/react-overlay

TypeScript typings are included (No @types/ package needed)

Usage

import { OverlayPortal } from '@stackmeister/react-overlay'
import { useState } from 'react'
import { render } from 'react-dom'

const App = () => {
  const [open, setOpen] = useState(false)

  return (
    <div class="app">
      <button type="button" onClick={() => setOpen(true)}>
        Open Overlay
      </button>

      {open && (
        <OverlayPortal>
          <div className="modal" style={{ position: 'absolute', top: 100, left: 100 }}>
            This will overlay everything by default

            <button type="button" onClick={() => setOpen(false)}>
              Close Overlay
            </button>
          </div>
        </OverlayPortal>
      )}
    </div>
  )
}

render(<App />, rootElement)

FAQs

Package last updated on 09 Nov 2022

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