🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

react-overlay-component

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-overlay-component

npm package to render overlay/modal with backdrop

1.0.6
latest
Source
npm
Version published
Weekly downloads
139
-40.85%
Maintainers
1
Weekly downloads
 
Created
Source

release open-issues Test Status Build Status license

react-overlay-component

renders an overlay/modal.

Install

npm install --save react-overlay-component

Usage

import React, { useState } from "react";
import Overlay from "react-overlay-component";

function App() {
    const [isOpen, setOverlay] = useState(false);

    const closeOverlay = () => setOverlay(false);

    const configs = {
        animate: true,
        // top: `5em`,
        // clickDismiss: false,
        // escapeDismiss: false,
        // focusOutline: false,
    };

    return (
        <div>
            <button
                className="primary"
                onClick={() => {
                    setOverlay(true);
                }}
            >
                open modal
            </button>

            <Overlay configs={configs} isOpen={isOpen} closeOverlay={closeOverlay}>
                <h2>Sample header</h2>
                <p>text content</p>

                <button
                    className="danger"
                    onClick={() => {
                        setOverlay(false);
                    }}
                >
                    close modal
                </button>
            </Overlay>
        </div>
    );
}

Demo

View demos: https://binodswain.github.io/react-overlay-component/

or

git clone git@github.com:binodswain/react-overlay-component.git
cd react-overlay-component

# build the package
npm install
npm build

# run example
cd example
npm install
npm start

Props

react-overlay-component requires isOpen, configs(optional), closeOverlay(optional) as props.

proptypeoptionaldescription
isOpenbooleanfalseflag to toggle the overlay
configsobjecttrueconfig object to customize overlay behavior
closeOverlayfunctiontruefunction that sets isOpen to false

configs

const configs = {
    animate: true,
    top: `5em`,
    clickDismiss: false,
    escapeDismiss: false,
    focusOutline: true,
    contentClass: "container overlay-content",
};
keytypeoptionaldefault valdescription
animatebooleantruetruetoggles overlay animation
topstringtrue0top value for overlay
clickDismissbooleantruetrueenables to close the overlay on clicking backdrop
escapeDismissbooleantruetrueenables to close the overlay on pressing ESC key
focusOutlinebooleantruefalseaddes an outline around the overlay-content div
contentClassstringtrue''additional class to add in overlay-content div

License

MIT © binodswain

Keywords

react

FAQs

Package last updated on 03 Dec 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