<main>
  <button id="btn-show-toast" type="button">👀 Show Toast</button>
  <div id="toast"></div>
</main>
body {
  font-family: 'Open Sans';
  background-color: #fafafa;
  margin: 0;
}

main {
 min-height: 100vh;
        display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex;
        -webkit-box-pack: justify; -moz-box-pack: justify; -ms-flex-pack: justify; -webkit-justify-content: center; justify-content: center;
        -webkit-align-items: center; -moz-align-items: center; -ms-align-items: center; align-items: center;
}

#btn-show-toast {
  outline: 0;
  background: #213cfd;
  color: #fff;
  border: 1px solid #000;
  padding: 10px 30px;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
}

#toast {
  position: fixed;
  bottom: -50px;
  width: 100%;
  max-width: 300px;
  background-color: #213cfd;
  background-image: linear-gradient(19deg, #213cfd 0%, #b421ff 100%);
  color: #fff;
  font-size: 16px;
  padding: 10px;
  -webkit-transition: bottom 350ms;
  -moz-transition: bottom 350ms;
  -o-transition: bottom 350ms;
  -ms-transition: bottom 350ms;
  transition: bottom 350ms;
  user-select: none;
}

#toast.active {
  bottom: 20px;
}

document.addEventListener("DOMContentLoaded", () => {
  let hasTime = null;
  document.querySelector('#btn-show-toast').addEventListener('click', (e) => {
    const toaster = document.querySelector('#toast');
    toaster.innerText = "✔️ This is a toast! 👏";
    toaster.classList.add('active');
    if(hasTime != null) {
      clearTimeout(hasTime);
    }
    hasTime = setTimeout(function() {
      toaster.classList.remove('active');
      toaster.innerText = "";
    }, 2000);
  });
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.