<div id="container">
  <span id="text">
    Click COPY button to copy this text to clipboard.
  </span>
  <button id="copy" tooltip="Copy to clipboard">Copy</button>
</div>
html,
body {
  width: 100%;
  height: 100%;
  font-size: 16px;
  font-family: "Quicksand", sans-serif;
  font-weight: 400;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  background-color: #e8ebee;
}
::selection {
  background-color: #000;
  color: white;
}
#container {
  display: flex;
  box-sizing: border-box;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 100px 50px;
  margin: 30px;
  box-shadow: 13px 13px 20px #caced1, -13px -13px 20px #fff;
  border-radius: 15px;
}
#text {
  box-sizing: border-box;
  background-color: #e8ebee;
  color: #000;
  border-radius: 15px;
  padding: 10px 15px;
  margin: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-family: "Quicksand", sans-serif;
  font-size: 1rem;
  font-weight: 300;
  letter-spacing: 1px;
  line-height: 1.5;
  box-shadow: inset 4px 4px 8px #caced1, inset -4px -4px 8px #fff;
}
#copy {
  position: relative;
  box-sizing: border-box;
  background-color: #482ff7;
  color: #fff;
  width: 180px;
  min-height: 44px;
  font-size: 1rem;
  font-family: "Jost", sans-serif;
  font-weight: 500;
  text-transform: uppercase;
  padding: 5px;
  border: 0;
  border-radius: 15px;
  outline: none;
  cursor: pointer;
  user-select: none;
  box-shadow: 13px 13px 20px #caced1, -13px -13px 20px #fff;
}
#copy:before {
  content: "";
  width: 16px;
  height: 16px;
  bottom: -20px;
  left: 82px;
  clip-path: polygon(50% 40%, 0% 100%, 100% 100%);
}
#copy:after {
  content: attr(tooltip);
  width: 140px;
  bottom: -48px;
  left: 20px;
  padding: 5px;
  border-radius: 4px;
  font-size: 0.8rem;
}
#copy:before,
#copy:after {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  box-sizing: border-box;
  background-color: #000;
  color: #fff;
  transform: translateY(-10px);
  transition: all 300ms ease;
}
#copy:hover:before,
#copy:hover:after {
  opacity: 1;
  transform: translateY(0);
}
const textElement = document.getElementById("text");
const copyButton = document.getElementById("copy");

const copyText = (e) => {
  window.getSelection().selectAllChildren(textElement);
  document.execCommand("copy");
  e.target.setAttribute("tooltip", "Copied! ✅");
};

const resetTooltip = (e) => {
  e.target.setAttribute("tooltip", "Copy to clipboard");
};

copyButton.addEventListener("click", (e) => copyText(e));
copyButton.addEventListener("mouseover", (e) => resetTooltip(e));

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.