Socket
Socket
Sign inDemoInstall

react-overlay-component

Package Overview
Dependencies
8
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-overlay-component

npm package to render overlay/modal with backdrop


Version published
Weekly downloads
48
decreased by-82.92%
Maintainers
1
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 29 Apr 2020

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc