Pen Settings



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


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


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.


Save Automatically?

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.


                <div id="container">
    <!-- This element's contents will be replaced with your component. -->


                .App {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: calc(10px + 2vmin);
  color: black;

body {
  background-image: url("");
  background-repeat: no-repeat;
  background-position: right left;
  background-attachment: fixed;

/* Background effect. It covers the entire site */
.modal {
  background-color: rgb(0,0,0); /* Fallback color */
  background-color: rgba(0,0,0,0.4); /* Overlay effect: translucent background: black w/ partial opacity */
  z-index: 1; /* Overlay effect: positioned over other containers */
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  position: fixed; /* Fix position on the top-left corner*/
  top: 0;
  left: 0;
  overflow: auto; /* Enable scroll if needed */
  padding-top: 80px; /* Location of the content container */

/* Modal content */
.modal-content {
  background-color: white;
  width: 70%; /* Width in proportion to its parent container*/
  max-width: 640px; /* Max width where it stops expanding */
  height: 70%; /* Height in proportion to its parent container */
  margin: auto; /* Auto margin according to the element width */
  padding: 10px;
  border: 1px solid black;
  border-radius: 20px; /* Optional. Rounds container corners */

.modal-flex {
  display: flex;
  height: 100%; 
  flex-direction: row;
  justify-content: center;
  align-items: center;

.modal-info {
  background-color: #888;
  border: 1px solid #888;

/* Close button */
.close {
  color: #aaaaaa;
  float: right; /* Positioned to the right of the parent container whichever size it is */
  font-size: 25px;
  font-weight: bold;

.close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;


                class App extends React.PureComponent {

  state = {
    modal: false,
    modalInfo: "",

  selectModal = (info = "") => {
      modal: !this.state.modal,
      modalInfo: info

  render() {
    return (
      <div className="App">
          <p onClick={ () => this.selectModal('Modal A') }>
            Open Modal A
          <p onClick={ () => this.selectModal('Modal B') }>
            Open Modal B

const Modal = props => {
  function displayInfo () {
    switch(props.modalInfo) {
      case 'Modal A':
        return <div className="modal-info">This is Modal A</div>
      case 'Modal B':
        return <div className="modal-info">This is Modal B</div>
        return null

  function closeModal (e) {

  let modal = (
      onClick={ closeModal }>

        <div className="modal-content"
          onClick={ e => e.stopPropagation() }>
            onClick={ closeModal }>&times;

          <div className="modal-flex">



    return ( props.displayModal ? modal : null);

  <App />,