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

@netojose/react-modal

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netojose/react-modal

A lightweight dialog component for React

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by9.09%
Maintainers
1
Weekly downloads
 
Created
Source

A lightweight dialog component for React

Demo

https://codesandbox.io/s/react-modal-example-3km0w

Install

npm i @netojose/react-modal

or

yarn add @netojose/react-modal

Basic usage

import React, { useState, useCallback } from 'react'
import Modal from '@netojose/react-modal'

function App() {
    const [isOpen, setIsOpen] = useState(false)
    const openModal = useCallback(() => setIsOpen(true), [])
    const closeModal = useCallback(() => setIsOpen(false), [])
    return (
        <div>
            <input type="button" value="Open modal" onClick={openModal} />
            <Modal isOpen={isOpen} onRequestClose={closeModal}>
                <p>This is the modal content</p>
                <input type="button" value="Close modal" onClick={closeModal} />
            </Modal>
        </div>
    )
}

export default App

API

propDescriptiontypedefault valuerequired
isOpenFlag to render or not the modalbooleanfalseYes
ariaLabelledbyaria-labelledby modal attributestringnullNo
ariaDescribedbyaria-describedby modal attributestringnullNo
onAfterOpenCallback after modal openfunction() => nullNo
onAfterCloseCallback after modal closefunction() => nullNo
onRequestCloseCallback when a close modal action is triggeredfunction() => nullNo
closeOnOverlayClickFlag to request close modal on overlay clickbooleantrueNo
closeOnEscFlag to request close modal on press esc keybooleantrueNo
focusAfterRenderFlag to modal should be focused after renderbooleantrueNo
portalClassNamePortal div class namestringReactModal__PortalNo
overlayClassNameOverlay div class namestringReactModal__OverlayNo
modalClassNameModal div class namestringReactModal__ModalNo
overlayStylesExtra overlay stylesobject{}No
modalStylesExtra modal stylesobject{}No
containerQuery selector to append portalstringbodyNo

Keywords

FAQs

Package last updated on 09 Jul 2019

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