Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="root"></div>
              
            
!

CSS

              
                .modal {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.25);
  animation-name: appear;
  animation-duration: 300ms;
}

.modal-dialog {
  border-radius: 5px 5px;
  width: 100%;
  max-width: 550px;
  background: white;
  position: relative;
  margin: 0 20px;
  max-height: calc(100vh - 40px);
  text-align: left;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  -webkit-animation-name: animatetop;
  -webkit-animation-duration: 0.4s;
  animation-name: slide-in;
  animation-duration: 0.5s;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  padding: 1rem;
}
.modal-header {
  border-bottom: 1px solid #dbdbdb;
  justify-content: space-between;
}
.modal-footer {
  border-top: 1px solid #dbdbdb;
  justify-content: flex-end;
}
.modal-close {
  cursor: pointer;
  padding: 1rem;
  margin: -1rem -1rem -1rem auto;
}
.modal-body {
  overflow: auto;
}
.modal-content {
  padding: 1rem;
}

@keyframes appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes slide-in {
  from {
    transform: translateY(-150px);
  }
  to {
    transform: translateY(0);
  }
}

.btn {
	box-shadow:inset 0px -3px 7px 0px #29bbff;
	background-color:#2dabf9;
	border-radius:3px;
	border:1px solid #0b0e07;
	display:inline-block;
	cursor:pointer;
	color:#ffffff;
	font-family:Arial;
	font-size:15px;
	padding:6px 20px;
	text-decoration:none;
	text-shadow:0px 1px 0px #263666;
}
.btn:hover {
	background-color:#0688fa;
}
.btn:active {
	position:relative;
	top:1px;
}

       
              
            
!

JS

              
                const Modal = ({ isVisible = false, title, children, footer, onClose }) => {
  
  React.useEffect(() => {
    document.addEventListener('keydown', keydownHandler);
    return () => document.removeEventListener('keydown', keydownHandler);
  });

  function keydownHandler({ key }) {
    switch (key) {
      case 'Escape':
        onClose();
        break;
      default:
    }
  }

  return !isVisible ? null : (
    <div className="modal" onClick={onClose}>

      <div className="modal-dialog" onClick={e => e.stopPropagation()}>
        
        <div className="modal-header">
          <div className="modal-title">{title}</div>
          <span className="modal-close" onClick={onClose}>&times;</span>
        </div>
        <div className="modal-body">
          <div className="modal-content">{children}</div>
        </div>
        {footer && <div className="modal-footer">{footer}</div>}
      </div>
    </div>
  );
}

//Add the component to the render function
function App() {
  const [isModal, setModal] = React.useState(false);

  return (
    <>
      <button onClick={() => setModal(true)}>Click Here</button>
      <Modal
        isVisible={isModal}
        title="Modal Title"
        footer={<button className="btn" onClick={() => setModal(false)}>Close</button>}
        onClose={() => setModal(false)}
        >
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus suscipit lorem at sapien commodo, vel varius sem lacinia. Praesent accumsan vestibulum massa, vitae faucibus justo ultrices posuere. Aenean et euismod erat. Vestibulum id pretium metus. Morbi magna libero, aliquet sit amet ante eu, dictum auctor mi. Sed quis venenatis nunc. Sed ac hendrerit nisi. Vestibulum dictum nisi dignissim, pulvinar velit sit amet, ultrices metus. Ut fermentum sed dolor quis malesuada. Fusce mollis venenatis cursus. Sed scelerisque enim fermentum ligula mattis porta. Etiam in dui mattis, mattis massa non, euismod quam. Donec condimentum ipsum neque, id sodales neque mollis eget. Proin suscipit ante leo, hendrerit pellentesque felis ornare non. Nam pretium pretium purus, in pretium dolor elementum sit amet. Proin viverra vel mauris suscipit venenatis.</p>
      </Modal>
    </>
  );
}

ReactDOM.render(<App />, document.getElementById('root'));
              
            
!
999px

Console