🌐
CodePen
codepen.io › dav3evans › pen › VgGVGb
React Modal Example
state = { show: false }; // Method to show modal, activated when you clicky the OPEN button showModal = () => { this.setState({ show: true }); }; // Method to hide modal, activated by handleClose prop on the <Modal> hideModal = () => { ...
🌐
CodePen
codepen.io › mike-grifin › pen › bwNQdQ
React Modal Ui
An Ova high chair is the right place for breakfast, lunch and dinner.", price: "€" + 89 }); }, render : function() { return( <div className="modal" data-status={this.props.status}> <div className="modal-left"> <span className="price-tag">...
🌐
CodePen
codepen.io › ph1p › pen › XjNONb
Easy react modal
"block" : "none" }} > <div style={this.style.overlay} onClick={this.props.closeModal} /> <div onClick={this.props.closeModal} /> <div style={this.style.modal}>{this.props.children}</div> </div> ); } } // overwrite style const modalStyle = { overlay: { backgroundColor: "rgba(0, 0, 0,0.5)" } }; const mainStyle = { app: { margin: "120px 0" }, button: { backgroundColor: "#408cec", border: 0, padding: "12px 20px", color: "#fff", margin: "0 auto", width: 150, display: "block", borderRadius: 3 } }; class App extends React.Component { constructor(props) { super(props); // set initial state this.state
🌐
CodePen
codepen.io › eedamame › pen › OxNejY
react-modal sample
.Modal { position: absolute; top: 50%; left: 50%; display: block; padding: 2em; min-width: 20em; max-width: 70%; color: #f00; background-color: #fff; border-radius: 1em; transform: translate(-50%, -50%); outline: transparent; } .Overlay { position: ...
🌐
CodePen
codepen.io › kotomoika › pen › RVOKxR
Modal window with React.js
.modal z-index 9999 position absolute top 50% left 50% min-width 250px min-height 100px padding 15px border-radius 10px transform translate(-50%, -50%) background #fff .bg z-index 9998 position absolute width 100% height 100% top 0 left 0 background ...
🌐
CodePen
codepen.io › tag › react-modal
Pens tagged 'react-modal' on CodePen
CodePen doesn't work very well without JavaScript · We're all for progressive enhancement, but CodePen is a bit unique in that it's all about writing and showing front end code, including JavaScript. It's required to use most of the features of CodePen · Need to know how to enable it?
🌐
CodePen
codepen.io › carloluis › pen › owQoQr
react-modal
const { render } = ReactDOM; const noop = () => {}; function create(Component, props) { return new Promise((resolve, reject) => { const root = document.body; const wrapper = document.getElementById('modal'); const cleanup = () => { ReactDOM.unmountComponentAtNode(wrapper); root.classList.remove('no-overflow'); //wrapper.remove(); }; root.classList.add('no-overflow'); const response = func => response => { cleanup(); func(response); }; const viewProps = { accept: response(resolve), close: response(reject) }; ReactDOM.render(<Component {...props} {...viewProps} />, wrapper); }); } class Modal ex
🌐
CodePen
codepen.io › andreasmcdermott › pen › LQNpbg
Bootstrap modal example (React modal)
// Instead the component expects a onClose callback that will be called when user clicks "Close". function MediaModal({children, onClose}) { return ( <div className="modal show" style={{display: 'block'}} > <div className="modal-dialog" role="document"> <div className="modal-content"> <div className="modal-header"> <h5 className="modal-title">Modal title</h5> <button type="button" className="close" aria-label="Close" onClick={onClose} > <span aria-hidden="true">&times;</span> </button> </div> <div className="modal-body">{children}</div> <div className="modal-footer"> <button className="btn btn-secondary" onClick={onClose} >Close</button> </div> </div> </div> </div> ); } ReactDOM.render( <MediaModal> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
🌐
CodePen
codepen.io › deammer › pen › LoMBvp
React modal using hooks
</p> <button type="button" onClick={onRequestClose}> Close this modal </button> <div className="placeholder" /> <div className="placeholder" /> <div className="placeholder medium" /> <div className="placeholder" /> </div> </div> ); }; const App = () => { const [isModalOpen, setModalIsOpen] = useState(false); console.log(useState("hello")[1]) const toggleModal = () => { setModalIsOpen(!isModalOpen); }; return ( <main> {isModalOpen && <Modal onRequestClose={toggleModal} />} <h1>React modal</h1> <p> This Pen shows an example of a controlled modal component built using React hooks, specifically <c
🌐
CodePen
codepen.io › bere › pen › PmrQKy
Simple Modal in React (ES6)
null : 'none', backgroundColor: bg || 'rgba(255, 255, 255, 0.8)', } }; return ( <div className="modal-wrapper" style={styles.modal}> { /* Close Button: invoke callback */ } <span className="glyphicon glyphicon-remove-sign modal-item" ...
Find elsewhere
🌐
CodePen
codepen.io › baranovxyz › pen › pojLjjB
Simple Modal in React - CodePen
.Modal { /* fixed position will always show modal in the top left corner */ position: fixed; top: 0; left: 0; /* z-index to show modal even if it is used before some other elements */ z-index: 5; /* make modal fill whole window */ width: 100vw; height: 100vh; /* add some background to blur content behind modal */ background: rgba(255, 255, 255, 0.8); /* center content inside modal */ display: flex; justify-content: center; align-items: center; } .Component { min-width: 200px; min-height: 100px; background-color: lightgreen; padding: 20px; } .App { width: 100vw; height: 100vh; text-align: cente
🌐
CodePen
codepen.io › jh3y › pen › RwNozBm
Basic Modal w/ React Portals
createPortal( <div className='modal'> <button onClick={onClose} className='modal__close'>&times;</button> {children} </div>, document.body) : null const App = () => { const [open, setOpen] = useState(false) return ( <Fragment> <button onClick={() => setOpen(!open)}>Show Modal?</button> <Modal open={open} onClose={() => setOpen(false)}> Test Modal </Modal> </Fragment> ) } render(<App/>, document.getElementById('app'))
🌐
CodePen
codepen.io › minhtranite › pen › yYqXpP
React Modal Bootstrap
Autem delectus est laborum minus modi molestias natus provident, quidem rerum sint, voluptas!</p> </ModalBody> </Modal> </ModalBody> <ModalFooter> <button className='btn btn-default' onClick={this.hideModal}> Close </button> <button className='btn ...
🌐
CodePen
codepen.io › examples-rocks › pen › jAxwKQ
React Modal Bootstrap Example
Autem delectus est laborum minus modi molestias natus provident, quidem rerum sint, voluptas!</p> </ModalBody> </Modal> </ModalBody> <ModalFooter> <button className='btn btn-default' onClick={this.hideModal}> Close </button> <button className='btn ...
🌐
CodePen
codepen.io › justen › pen › jVvQZP
React Custom Modal Component - CodePen
import * as reactDraggable from "https://cdn.skypack.dev/react-draggable@4.4.4"; class App extends React.Component { constructor(props) { super(props) this.state = { isModalOpen: false } } render() { return ( <div> <button onClick={() => this.openModal()}>Open modal</button> <Modal width={950} height={340} noBackdrop={true} isOpen={this.state.isModalOpen} onClose={() => this.closeModal()} > <h1>Content goes here.</h1> </Modal> </div> ) } openModal() { this.setState({ isModalOpen: true }) } closeModal() { this.setState({ isModalOpen: false }) } } class Modal extends React.Component { render() {
🌐
CodePen
codepen.io › andreasmcdermott › pen › wyGKmW
Bootstrap modal example (with React modal hooked up)
We found that this method generally caused us less grief. ReactDOM.render( <div> {this.isOpen && <MediaModal onClose={this.handleClose}> <p> {this.content} </p> </MediaModal>} </div>, this.element ); } } // This has barely changed.
🌐
CodePen
codepen.io › IamAhmedHamed › pen › aMyorJ
The perefect React Modal || Dialog ? - CodePen
<h1 className='display-3' style={{color: 'red'}}>Something went WRONG</h1> : this.props.children; } } // end ErrorBoundary // the modal component class Modal extends React.Component { constructor(props) { super(props); this.state = {className: ...
🌐
CodePen
codepen.io › Laumak › pen › pRJzGL
React + Bulma Modal
const Modal = ({ children, closeModal, ... className="section"> <div className="container"> <div className="has-text-centered content"> <h1 className="title">React + Bulma modal example</h1> <hr /> <a className="button is-primary" ...
🌐
CodePen
codepen.io › focuswish › full › ENJjzL
CodePen - React Modal Example
This is an example of how you could implement a modal in ReactJS. ...
🌐
CodePen
codepen.io › shantanu-jana › pen › eYVbGvp
Modal Popup in React JS
Facere, rem. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Facere, rem.") ))); } ReactDOM.render( /*#__PURE__*/ React.createElement(App, null), document.getElementById('app')); </script> </body> </html>