<button id="btnParty" type="button">Party!!</button>
<div id="tsparticles"></div>
body {
  background: #000;
}

#tsparticles canvas {
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
  left: 0 !important;
  top: 0 !important;
  pointer-events: none !important;
}

button {
  position: absolute;
  width: 200px;
  height: 100px;
  top: 50%;
  left: 50%;
  margin-top: -50px;
  margin-left: -100px;
  z-index: 1000;
  font-size: 32pt;
  border-radius: 20px;
  background: #fff;
  border: none;
  cursor: pointer;
}

button:active {
  color: #f00;
}
btnParty.addEventListener("click", () => {
  confetti("tsparticles", {
    angle: 90,
    count: 25,
    position: { x: 50, y: 50 },
    spread: 90,
    startVelocity: 60,
    decay: 0.9,
    gravity: 1,
    drift: 0,
    ticks: 200,
    colors: ["#fff", "#f00"],
    shapes: ["square", "circle"],
    scalar: 1,
    zIndex: 2000,
    disableForReducedMotion: true
  });
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdn.jsdelivr.net/npm/tsparticles-preset-confetti@1.16.1/tsparticles.preset.confetti.bundle.min.js