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

              
                <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/gh/lekoala/pop-notify/pop-notify.css" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
<script type="module" src="https://cdn.jsdelivr.net/gh/lekoala/pop-notify@master/pop-notify.min.js"></script>

<div class="p-3">

  <pop-notify autohide>
    <div class="notification notification-simple">
      Welcome to pop notify! <button type="button" class="btn-close" aria-label="Close"></button>
    </div>
  </pop-notify>

  Position
  <select id="position">
      <option>end</option>
      <option>start</option>
      <option>left</option>
      <option>right</option>
      <option>center</option>
      <option>top-end</option>
      <option>top-start</option>
      <option>top-left</option>
      <option>top-center</option>
      <option>top-right</option>
      <option>bottom-end</option>
      <option>bottom-start</option>
      <option>bottom-left</option>
      <option>bottom-center</option>
      <option>bottom-right</option>
    </select>

  <hr>

  <button type="button" class="btn btn-primary mb-3" id="simpleNotification">A simple notification</button>

  <button type="button" class="btn btn-primary mb-3" id="errorNotification">An error notification</button>

  <button type="button" class="btn btn-primary mb-3" id="questionNotification">A question notification</button>

  <button type="button" class="btn btn-primary mb-3" id="infoNotification">An info notification</button>

  <button type="button" class="btn btn-primary mb-3" id="complexNotification">A complex success notification</button>

  <button type="button" class="btn btn-primary mb-3" id="stickyNotification">A more complex sticky notification</button>

  <button type="button" class="btn btn-primary mb-3" id="toastBtn">Show toast</button>

  <button type="button" class="btn btn-primary mb-3" id="autohideToastBtn">Show autohide toast</button>
  
  <p><a href="https://github.com/lekoala/pop-notify/">Repo</a></p>

</div>
              
            
!

CSS

              
                /* Avoid fouc */
pop-notify:not(:defined) {
  display: none;
}

              
            
!

JS

              
                customElements.whenDefined("pop-notify").then(() => {
  console.log("READY!");
  
  let id = 0;
  function createBootstrapToast() {
    id++;

    return `
<div id="toast-${id}" class="toast show" role="status">
<div class="toast-header">
<div class="me-2">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-exclamation-circle-fill" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8 4a.905.905 0 0 0-.9.995l.35 3.507a.552.552 0 0 0 1.1 0l.35-3.507A.905.905 0 0 0 8 4zm.002 6a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/>
</svg>
</div>
<strong class="me-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="toast-body">
Hello, world! This is a toast message nb ${id}.
</div>
</div>
</div>
`;
  }

  function popNotify() {
    return customElements.get("pop-notify");
  }

  // Example integration
  popNotify().configure({
    iconTransformer: (icon) => {
      return `<span class="material-symbols-outlined">${icon}</span>`;
    }
  });

  document
    .querySelector("#simpleNotification")
    .addEventListener("click", (ev) => {
      popNotify().notifyHtml(
        `<div class="notification notification-simple">A simple notification! <button type="button" class="btn-close" aria-label="Close"></button></div>`
      );
    });

  document
    .querySelector("#errorNotification")
    .addEventListener("click", (ev) => {
      popNotify().notify(
        "Nope you can't do that. <a href='/retry'>Retry one more time ?</a>",
        {
          variant: "error",
          icon: "error",
          onclick: (ev, inst) => {
            ev.preventDefault();
            popNotify().notify("You really thought it would work???", {
              variant: "error",
              icon: "error"
            });
          }
        }
      );
    });

  document
    .querySelector("#questionNotification")
    .addEventListener("click", (ev) => {
      popNotify().notify("What do you think ?", {
        variant: "question",
        icon: "help"
      });
    });

  document
    .querySelector("#infoNotification")
    .addEventListener("click", (ev) => {
      popNotify().notify("This is something you should know", {
        variant: "info",
        icon: "info"
      });
    });

  document
    .querySelector("#complexNotification")
    .addEventListener("click", (ev) => {
      popNotify().notify(
        "This is the body. Ithasawordthathasnobreakingspacebutshouldneverthelessnotexpandoutsideofthetoast",
        {
          variant: "success",
          header: "Success!",
          icon: "check"
        }
      );
    });

  document
    .querySelector("#stickyNotification")
    .addEventListener("click", (ev) => {
      popNotify().notify("It doesn't close automatically", {
        variant: "warning",
        header: "Sticky!",
        autohide: false,
        icon: "warning",
        actions: [
          {
            label: "Some action",
            class: "btn-warning",
            onclick: (ev, inst) => {
              alert("You clicked on some action");
            }
          },
          {
            label: "Just close",
            class: "btn-dark",
            onclick: (ev, inst) => {
              inst.close();
            }
          }
        ]
      });
    });

  document.querySelector("#toastBtn").addEventListener("click", (ev) => {
    popNotify().notifyHtml(createBootstrapToast(), false);
  });

  document
    .querySelector("#autohideToastBtn")
    .addEventListener("click", (ev) => {
      popNotify().notifyHtml(createBootstrapToast());
    });

  document.querySelector("#position").addEventListener("change", (ev) => {
    console.log(`position changed to ${ev.target.value}`);
    popNotify().configure({
      placement: ev.target.value
    });
  });
});

              
            
!
999px

Console