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.


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.


<main class="row h-100dvh font-industrial">
  <div class="stack stack--large">
      <h1 class="h1">Dialog controlled out animation</h1>

<button type="button" id="open">Open</button>

<dialog class="font-industrial">
  <p>This is a dialog. Lorem ipsum dolor sit amet consectetur adipisicing elit. Totam explicabo id molestiae dolorum sapiente beatae voluptatibus ut dignissimos! Culpa esse reiciendis amet voluptas, hic facilis temporibus. Earum eos consectetur similique!</p>
  <button  type="button" id="close">Close</button>



                .h-100dvh {
  height: 100dvh;
  display: flex;
  justify-content: center;
  flex-direction: column;
  text-align: center;

button {
  margin: auto;

dialog {
  contain: paint;
  border: 1px solid var( --pastel);
  opacity: 0;

dialog[open] {
  text-align: left;
  display: block;
  animation: open 0.3s ease-out;
  animation-fill-mode: both;
  width: min(90vw, 750px); 
  box-shadow: 0 0 0 100000px var(--content);
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);

dialog[closing] {
  animation: close 0.3s ease-out;
  animation-fill-mode: both;

@keyframes open {
  0% { opacity: 0; }
  100% { opacity: 1; }

@keyframes close {
  0% { opacity: 1; }
  99% { opacity: 0; }
  100% { display: none; }


                const openButton = document.querySelector('#open');
const closeButton = document.querySelector('#close');
const dialog = document.querySelector('dialog');

openButton.addEventListener('click', () => {;
closeButton.addEventListener('click', () => {
  dialog.setAttribute('closing', true)
  setTimeout(() => {
  }, 400);

window.addEventListener('keydown', (e) => {
  if (e.key === 'Escape') {
    dialog.setAttribute('closing', true)
    setTimeout(() => {
    }, 400)