React Modal Button
Button that takes a modal as prop
Installation
npm i --save react-modal-button
Example
Usage
;; const App = <div> <h1>React Modal Button!</h1> <ModalButton modal= <div> <p>My Modal</p> <button onClick=closeModal>Close</button> </div> > Button Text Here 🐕 </ModalButton> </div>;
Props for content
prop | render prop |
---|---|
modal | closeModal |
Props on Button
props | defualt |
---|---|
buttonStyle | |
buttonClassName |
Props for Modal
props | Default |
---|---|
isBackdrop | false |
showCloseButton | true |
closeOnBackdrop | true |
closeOnEsc | true |
height | '300px' |
width | '500px' |
animation | 'fade' |
animationDurationMS | 300 |
className | |
windowClassName | |
windowStyles | |
backdropClassName | |
backdropStyles |
Custom Animation
modal-[your-animation-prop]-on-[enter/leave]
Control the modal with state
; state = isModalOpen: false ; { this; }; { this; }; { return <div> <button onClick=thisopenModal>Open Modal</button> <Modal isOpen=thisstateisModalOpen onClose=thiscloseModal> <div>Content</div> <button onClick=thiscloseModal>Close Modal</button> </Modal> </div> ; }