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 class="overlay-toggle"><label>Transition overlay<input type=checkbox checked></label></div>

<div class="app">
  <h2>Account Actions</h2>
  <p>This might be a section in your preferences where you can take some actions on your account.</p>
  <h3>Delete account</h3>
  <p>Delete your account forever. This is the button you click to open the dialog in this demo.</p>
  <div class="actionbar">
    <button onclick="document.querySelector('dialog').showModal();">Delete</button>
  </div>
  <h3>Archive Account</h3>
  <p>Archive your account for now. Note: this is a demo, you can't click on this button.</p>
  <div class="actionbar">
    <button disabled>Archive</button>
  </div>
</div>

<dialog>
  <div class="top">
    <h2>Delete this user account</h2>
    <button class="close-btn" onclick="document.querySelector('dialog').close();">
     <p aria-hidden="true">❌</p>
     <p class="sr-only">Close dialog</p>
    </button>
  </div>
  <div class="dialog-text">
  <p><span class="warn-icon">
    <?xml version="1.0" encoding="UTF-8"?>
<svg id="Isolation_Mode" data-name="Isolation Mode" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 110.64 101.43">
  <path class="cls-1" d="m38,9.45L2.28,74.41c-6.76,12.3,2.33,27.31,16.36,27.02l74.12-1.55c14.03-.29,22.49-15.67,15.22-27.68L69.58,8.79c-7.27-12.01-24.82-11.64-31.58.66h0Z"/>
  <path class="cls-2" d="m47.86,22.39l13.77-.29-.66,44.8-10.48.22-2.63-44.73h0Zm2.3,50.6l10.88-.23.21,10.13-10.88.23-.21-10.13Z"/>
</svg>
  </span>Warning: This is a destructive action.</p>
  <button id="anchor-btn" class="info-btn" popovertarget="my-tooltip">
    <p aria-hidden="true">?</p>
    <p class="sr-only">Open Tooltip</p>
  </button>
  </div>
  <form method="dialog">
    <button class="confirmation-btn">Confirm deletion</button>
  </form
</dialog>

<p id="my-tooltip" class="info-tooltip" anchor="anchor-btn" popover>"Destructive action" means that this cannot be undone. Do not open a ticket. You've been warned. Good luck.
</p>
              
            
!

CSS

              
                /* Animation things */
[popover],
dialog,
::backdrop{
  opacity: 0;
  transition: opacity 1s, display 1s allow-discrete;
}

:popover-open,
[open],
[open]::backdrop {
  opacity: 1;
}

@starting-style {
  :popover-open,
  [open],
  [open]::backdrop {
    opacity: 0;
  }
}

.overlay, .overlay::backdrop {
  transition: opacity 1s, display 1s allow-discrete, overlay 1s allow-discrete;
}

::backdrop {
  background-color: rgba(0,0,0,.6);
}

/* ETC */
@import url('https://fonts.googleapis.com/css2?family=Anybody&display=swap');

:root {
  --orange: #ff7b22;
}

.warn-icon svg {
  rotate: -10deg;
  vertical-align: middle;
  width: 2rem;
}

dialog {
  border: 6px solid var(--orange);
  border-radius: 1rem;
  padding: 2rem;
  min-width: 300px;
}

.dialog-text {
  display: flex;
  line-height: 0;
  margin-bottom: 2rem;
}

.confirmation-btn {
  color: var(--orange);
  border: 3px solid var(--orange);
  border-radius: 1rem;
  transition-duration: 0.25s;

  &:hover {
    background: var(--orange);
    color: white;
  }
}

.close-btn {
  position: absolute;
  top: 0.1rem;
  right: 0.6rem;
  border: 0;
  background: none;
  filter: grayscale(1);
}

.info-tooltip {
  --spacer: 0.25rem;
  position-fallback: --top-then-bottom;
  translate: -50% 0;
  font-size: 90%;
  background: #222;
  color: white;
  border: none;
  padding: 1rem;
  max-width: 200px;
}

@position-fallback --top-then-bottom {
  @try {
    bottom: calc(anchor(top) + var(--spacer));
    left: anchor(center);
  }

  @try {
    top: calc(anchor(bottom) + var(--spacer));
    left: anchor(center);
  }
}

dialog h2 {
  margin: 2rem 0;
}

.info-btn {
  background: gold;
  font-weight: 800;
  border-radius: 1.2rem;
  height: 1.5rem;
  width: 1.5rem;
  display: grid;
  place-content: center;
  border: 2px solid var(--orange);
  transition-duration: 0.25s;
  margin-top: 0.5rem;
  
  &:hover {
    background-color: blue;
    color: white;
  }
}

body {
  font-family: 'Anybody', system-ui, sans-serif;
  font-size: 1.1rem;
  line-height: 1.4;
  margin: 0;
}

h2 {
  line-height: 1;
}

.sr-only {
  clip: rect(0 0 0 0); 
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap; 
  width: 1px;
}

.overlay-toggle {
  position: fixed;
  top: 0;
  width: 100%;
  background: gold;
  font-weight: 700;
  padding: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.app {
  margin: 5rem auto 0;
  padding: 1rem 3rem 2rem;
  border: 6px solid blue;
  border-radius: 1rem;
  width: clamp(200px, 60vw, 500px);
}

button {
  border: 3px solid blue;
  border-radius: 1rem;
  background: white;
  padding: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  font-size: 100%;
  text-transform: uppercase;
  font-family: Anybody, system-ui;
  
  :is(disabled) {
    border-color: lightgray;
  }
}

/* SVG */
.cls-1 {
  fill: #1601f2;
}

.cls-2 {
  fill: #fff;
}
              
            
!

JS

              
                const checkbox = document.querySelector('input');

const updatecheckbox = () => {
  document.querySelectorAll('[popover], dialog').forEach(elem => {
    if (checkbox.checked) {
      elem.classList.add('overlay');
    } else {
      elem.classList.remove('overlay');
    }
  });
};
updatecheckbox();
checkbox.onchange = updatecheckbox;
              
            
!
999px

Console