Frontend Blocks typescript Intermediate

Canvas Confetti on Success

Trigger a canvas-confetti burst when a user completes an action.

typescript
import confetti from "canvas-confetti";

export function celebrate() {
  confetti({
    particleCount: 120,
    spread: 80,
    origin: { y: 0.6 },
    colors: ["#22c55e", "#16a34a", "#4ade80"],
  });
}

// Usage: call celebrate() after a successful donation
document.getElementById("pay-btn")?.addEventListener("click", celebrate);

Prerequisites

  • canvas-confetti >= 1.9

Pro Tips

  • → Wrap in a try/catch — canvas may be blocked by strict CSP.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
typescript
Level
Intermediate
Read time
1 min
Published
Jul 2026
License
Commercial License

Newsletter

New modules every week, directly to your inbox.