<span> Send Message </span>
@import url("https://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i&subset=devanagari,latin-ext");

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

body {
  background-color: #343a40;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  user-select: none;
}

span {
    user-select:none;
    position: relative;
    background: rgba(116, 23, 231, 1);
    color: #ffffff;
    background: transparent;
    border: 2px solid;
    transition: all 0.25s ease;
    width: 220px;
    height: 50px;
    padding: 20px;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    justify-content: center;
    align-items: center;
    display: flex;
  }

  span:hover{
    background: rgba(116, 23, 231, 1);
  }

.loading-1 {
  position: absolute;
  left: 0px;
  bottom: 0px;
  width: 0%;
  height: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(116, 23, 231, 0.8);
  animation: loading 2s ease infinite;
}

@keyframes loading {
  0% {
    width: 0%;
    left: 0px;
    right: auto;
  }
  50% {
    width: 100%;
    left: 0px;
    right: auto;
  }
  51% {
    width: 100%;
    left: auto;
    right: 0px;
  }
  100% {
    width: 0;
    left: auto;
    right: 0px;
  }
}
   var button = document.querySelector("span");
    button.addEventListener("click", () => {
      button.innerHTML = `<div class="loading-1">Sending</div>`;
      setTimeout(() => {
        button.innerText = "Done";
      }, 5000);
    });

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.