DEV Community

dan
dan

Posted on

Making React Apps Delightful with Confetti Effects

React is powerful but sometimes, even with beautiful logic and data flow, the user experience can feel dry. What if we could add a little joy when users complete tasks?

Let’s explore how to make your React apps more delightful using a simple confetti explosion when users achieve something awesome!


Why Add Delight?

Think about the last time you saw fireworks in an app maybe when you finished a task in Duolingo or submitted a form in Notion. These tiny micro-interactions:

  • Reinforce user progress
  • Add emotional engagement
  • Encourage repeat use

With React, you can do this easily using react-confetti or canvas-confetti.


Setup: Using canvas-confetti

Let’s create a Task Completion Confetti Effect in a React app:

1. Install the library

npm install canvas-confetti
Enter fullscreen mode Exit fullscreen mode

2. Import and trigger confetti

import confetti from "canvas-confetti";

function celebrate() {
  confetti({
    particleCount: 100,
    spread: 70,
    origin: { y: 0.6 },
  });
}
Enter fullscreen mode Exit fullscreen mode

You can trigger this function when:

  • A task is marked complete

  • A quiz is passed

  • A form is submitted

3. Hook It Up to a Button

function CongratsButton() {
  return (
    <button onClick={celebrate}>
      I Did It! 
    </button>
  );
}
Enter fullscreen mode Exit fullscreen mode

4. Bonus: Trigger Only Once

import { useState } from "react";

function TaskDone() {
  const [done, setDone] = useState(false);

  function handleClick() {
    if (!done) {
      confetti();
      setDone(true);
    }
  }

  return <button onClick={handleClick}>Complete Task</button>;
}
Enter fullscreen mode Exit fullscreen mode

What You Just Learned

  • You can add meaningful micro-interactions in React

  • canvas-confetti works well without complex setup

  • Emotion matters in UX — make users feel rewarded!

Try This Next

  1. Add sound feedback using use-sound

  2. Combine with a progress bar

  3. Animate button transforms with framer-motion

Final Thoughts

Don't underestimate the power of small delights. Whether you're building a to-do app, a quiz, or a learning tool a little confetti can go a long way in turning your app from useful to joyful.

Top comments (0)