Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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.





                /* Base component styling */
toast-notification {
  opacity: 0;
  text-align: center;
  border-radius: 8px;
  padding: 4px 8px;
  position: fixed; 
  z-index: 999; /* Make sure the it's on top of everything */
  top: 24px;
  transition: opacity 0.25s; /* Fade in and out */
  left: 50%;
  transform: translateX(-50%); /* Horizontally center it on the page */
  height: auto;
  background: blue;
  color: white;

/* Set opacity when set as visible in the attribute module  */
toast-notification[am-visible~=true] {
  opacity: 1;

/* Add space for the 'x' to dismiss a dismissible Toast  */
toast-notification[am-dismissible] {
  padding-right: 32px;
  pointer-events: none; /* Disable pointer events on the Toast; we only want the 'x' to be clickable */

/* Configure the 'x' to dismiss the Toast */
toast-notification[am-dismissible]:after {
  position: absolute;
  content: '✕';
  text-align: center;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  pointer-events: all; /* Allow pointer events only on the 'x' */



                class Toast extends HTMLElement {

  // This is called whenever a Toast element connects to the DOM
  connectedCallback() {
  show() {
    this.isVisible = true
    // If it's dismissible then we add a click listener to hide the toast
    if (this.isDismissible) {
      this.addEventListener("click", () => {
    // Otherwise we just hide it after 5 seconds  
    } else {
  hide(delay) {
    setTimeout(() => {
      this.isVisible = false
    }, delay)
    // 1 second after hiding the toast, we remove it from the DOM
    setTimeout(() => {
    }, delay + 1000)
  get isVisible() {
    return this.getAttribute("am-visible") || false
  set isVisible(visible) {
    this.setAttribute("am-visible", visible)
  get isDismissible() {
    return this.getAttribute("am-dismissible") != null

customElements.define('toast-notification', Toast)