🌐
CodePen
codepen.io › focuswish › pen › ENJjzL
React Modal Example
const display = { display: 'block' }; const hide = { display: 'none' }; class Modal extends React.Component { constructor(props) { super(props); this.toggle = this.toggle.bind(this); this.state = { toggle: false } } toggle(event) { this.setState((prevState) => ({ toggle: !prevState.toggle })); } render() { var modal = []; modal.push( <div className="modal" style={this.state.toggle ?
🌐
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 › 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 › ph1p › pen › XjNONb
Easy react modal
class Modal extends React.Component { static propTypes = { isModalOpen: React.PropTypes.bool.isRequired, closeModal: React.PropTypes.func.isRequired, style: React.PropTypes.shape({ modal: React.PropTypes.object, overlay: React.PropTypes.object }) }; constructor(props) { super(props); this.outerStyle = { position: "fixed", top: 0, left: 0, width: "100%", height: "100%", overflow: "auto", zIndex: 1 }; // default style this.style = { modal: { position: "relative", width: 500, padding: 20, boxSizing: "border-box", backgroundColor: "#fff", margin: "40px auto", borderRadius: 3, zIndex: 2, textAlign:
🌐
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 › 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 › carloluis › pen › owQoQr
react-modal
#app { height: 2000px; background: pink; } .no-overflow { overflow: hidden; } * { box-sizing: border-box; } .backdrop { overflow: auto; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 11; background-color: rgba(36, 45, 52, 0.5); .modal { position: relative; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 12; height: 250px; width: 400px; animation: in 0.4s ease-out; border-radius: 6px; background-color: white; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.2); padding: 24px; &.out { animation: out 0.4s ease-out; animation-fill-mode: forwa
🌐
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 › 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 › 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 › 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 › Jdure › pen › povLxVm
React-Bootstrap Modal
var Button = ReactBootstrap.Button; ... = React.createClass({ getInitialState() { return { showModal: false }; }, close() { this.setState({ showModal: false }); }, open() { this.setState({ showModal: true }); }, render() { return ( <div> <p>Click to get ...
🌐
CodePen
codepen.io › focuswish › full › ENJjzL
CodePen - React Modal Example
This is an example of how you could implement a modal in ReactJS. ...