2.0.1 • Published 5 months ago
simple-modal-jr-lib v2.0.1
simple-modal-jr-lib
Simple modal library
Install
npm install --save simple-modal-jr-lib
Usage
import React, { useState } from 'react'
import Modal from 'simple-modal-jr-lib'
import 'simple-modal-jr-lib/dist/index.css'
export default function Example() {
const [openModal, setOpenModal] = useState(false) // this hook will determine when the modal opens or closes
return (
<div className='Example'>
<h1>Modal Test</h1>
<button onClick={() => setOpenModal(true)}>Open Modal</button>{' '}
{/* We set the OpenModal hook on true to open the modal when we click on the button */}
<Modal isOpen={openModal} onClose={() => setOpenModal(false)}>
<p>Exemple text !</p>
</Modal>
{/* The modal component needs at least the 'setIsOpen' and the onClose function */}
</div>
)
}
## License
MIT © [RenierJordan](https://github.com/RenierJordan)
Customisation
Props | Description | Type |
---|---|---|
isOpen | /!\Required/!\ this will allow the component to change the state to "false" to close the modal | boolean |
onClose | /!\Required/!\ this will be called to close the modal | function |