Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minimal-react-modal

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

minimal-react-modal

a minimalistic react modal component

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

minimal-react-modal

A minimalistic react modal component.

Installation

npm i minimal-react-modal

Usage

The bare minimal usage of this library is as follows:

import * as React from 'react';
import {ModalContainer, Modal} from 'minimal-react-modal';

React.render(
  <ModalContainer>
    {(openModal, closeModal, isActive) => (
      <div>
        <button onClick={openModal}>click me!</button>
        <Modal
          isActive={isActive}     // required
          closeModal={closeModal} // required
        >
          <h1>modal content</h1>
        </Modal>
      </div>
    )}
  </ModalContainer>
);

demo_minimal

ModalContainer

The area where you can call the open/close functions (openModal / closeModal) and access the modal's state (isActive).

Props

propNametyperequireddefaultdescription
activeOnLoadbooleanxfalsewhether the modal should be active on load

Modal

The modal component itself. You must pass the close function (closeModal) and the modal status (isActive) provided by the parent ModalContainer component as props.

Props

propNametyperequireddefaultdescription
isActivebooleano-(provided by ModalContainer)
closeModal() => voido-(provided by ModalContainer)
classNamestringxnullclassname(s) to append to the modal box
showCloseButtonbooleanxfalsewhether to show the close button on the top right corner
showAnimationbooleanxfalsewhether to animate modal opening
modalBoxStyleReact.CSSPropertiesx{}overrides modal styles
closeButtonStyleReact.CSSPropertiesx{}overrides default close button style (make sure showCloseButton is true)
overlayStyleReact.CSSPropertiesx{}overrides modal background overlay style

Here is another demo utilizing these optional props:

<ModalContainer>
  {(openModal, closeModal, isActive) => (
    <>
      <button onClick={openModal}>click me!</button>
      <Modal
        isActive={isActive}     // required
        closeModal={closeModal} // required
        className="demo"
        showCloseButton={true}
        showAnimation={true}
        modalBoxStyle={{
          width: 500,
          height: 300,
          padding: 30,
        }}
      >
        <h1>modal content</h1>
      </Modal>
    </>
  )}
</ModalContainer>

demo

Keywords

FAQs

Package last updated on 24 Nov 2018

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc