react-modal-partial

a fully customized Modal for react with the help of react partial

Usage no npm install needed!

<script type="module">
  import reactModalPartial from 'https://cdn.skypack.dev/react-modal-partial';
</script>

README

react-modal-partial


package version Provider a simple react modal component created via react partials

Setup

npm

 npm install --save react-modal-partial
and import it
import useModal from 'react-modal-partial'

Usage

import React from 'react'
import useModal from 'react-modal-partial'
const Example = () => {
    const [ModaWrapper,open,close,isOpen] = useModal('root')
    return (
        <div>
            <button onClick={open}>open Modal</button>
            <ModalWrapper>
                <div>
                    modal content
                </div>
            </ModalWrapper>
            <button onClick={close}>close Modal</button>
        </div>
    )
}

export default Example

API

const [ModalWrapper,open,close,isOpen]=useModal(element id,options)
name description
ModalWrapper A react modal that wraps the whole content of your modal
open function that opens modal(your modal is not open until you call this function
close function that closes the modal
isOpen a boolean that represents if modal is close or open
options it's an object that has "preventScroll" key set it to true if you want to prevent scrolling when modal is open
element id that element id that you want to create your partial in it