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

              
                <dialog id="dialog">
  <form method="dialog">
    <p>Hi, I'm a dialog.</p>
    <button>OK</button>
  </form>
</dialog>

<button onclick="dialog.showModal()">Open Dialog</button>
              
            
!

CSS

              
                dialog {
  /* exit stage position of the dialog */
  transform: translateY(-20px);
  
  /* off stage opacity and default transition styles */
  /* allow-discrete is a `transition-behavior` */
  &, &::backdrop {
    transition: 
      /* time display none/block with the transitions */
      display 1s allow-discrete,
      /* time top-layer projection with the transitions */
      overlay 1s allow-discrete,
      /* transition opacity */
      opacity 1s,
      /* transition transforms */
      transform 1s;

    /* both dialog and it's backdrop are opacity 0 */
    /* when not showing */
    opacity: 0;
  }
  
  /* on stage styles */
  /* apply when dialog is shown */
  &[open] {
    opacity: 1;
    transform: translateY(0px);
    
    &::backdrop {
      opacity: 1;
    }
  }
  
  /* entering stage styles */
  /* used on first render when dialog has been */
  /* cloned and projected into the top-layer */
  @starting-style {
    &[open], 
    &[open]::backdrop {
      opacity: 0;
    }
    
    /* specific transform for dialog and not the backdrop */
    /* enter stage from 20px below the on stage resting style */
    &[open] {
      transform: translateY(20px);
    }
  }
}

::backdrop {
  background-image: 
    radial-gradient(
      circle at 1px 1px, 
      light-dark(#0007, #fff1) 1px, 
      #000c 0
    );
  background-size: 20px 20px;
}

html {
  block-size: 100%;
  color-scheme: dark light;
}

body {
  min-block-size: 100%;
  font-family: system-ui, sans-serif;
  
  display: grid;
  place-content: center;
  margin: 0;
}
              
            
!

JS

              
                
              
            
!
999px

Console