Free · MIT · React + Tailwind

React Confetti Component

A lightweight confetti burst for React and Tailwind CSS with deterministic pieces, a replay button and reduced-motion protection. No canvas or animation package required.

Copy the code

'use client'
import { useState } from 'react'
const pieces = Array.from({ length: 32 }, (_, i) => ({ left: (i * 41) % 100, delay: (i % 8) * 60 }))
export function ConfettiButton() {
  const [active, setActive] = useState(false)
  return (
    <div className="relative grid min-h-52 place-items-center overflow-hidden">
      {active && pieces.map((piece, i) => <span key={i} aria-hidden="true"
        className="absolute top-0 h-3 w-2 animate-bounce bg-violet-500 motion-reduce:hidden"
        style={{ left: piece.left + '%', animationDelay: piece.delay + 'ms' }} />)}
      <button onClick={() => { setActive(false); requestAnimationFrame(() => setActive(true)) }} className="relative rounded-xl bg-violet-600 px-5 py-3 font-bold text-white">Celebrate</button>
    </div>
  )
}

Tailwind CSS · no dependencies · MIT licensed. Paste it straight into any React, Next.js or Vite project.

About the react confetti

This react confetti is part of Empire UI - a free, open-source library of 34+ component types rendered across 41 visual styles, from glassmorphism to neo-brutalism. Every block is copy-paste ready in React and Tailwind CSS with no runtime dependencies.

Want it in a different look? Browse all 41 styles or grab the matching glassmorphism components.