Confetti animations are best used to delight your users when something special happens
Install
Add it to your project
Run this in a project set up for shadcn/ui. It writes the files and installs the npm packages.
First time: connect the Infinity UI registry
- Create a personal token on your Tokens page.
- Put it in
.env.localasINFINITYUI_TOKEN. - Add the registry to
components.json:
{
"registries": {
"@infinityui": {
"url": "https://infinityui.io/r/{name}.json",
"headers": {
"Authorization": "Bearer ${INFINITYUI_TOKEN}"
}
}
}
}Using Claude Code, Codex, Cursor, Lovable or v0? See CLI & MCP for a setup prompt.
npm packages it adds
- canvas-confetti
- @types/canvas-confetti
Code
"use client"
import { useRef } from "react"
import { Confetti, type ConfettiRef } from "@/registry/magicui/confetti"
export default function ConfettiDemo() {
const confettiRef = useRef<ConfettiRef>(null)
return (
<div className="bg-background relative flex h-[500px] w-full flex-col items-center justify-center overflow-hidden rounded-lg border">
<span className="pointer-events-none bg-linear-to-b from-black to-gray-300/80 bg-clip-text text-center text-8xl leading-none font-semibold whitespace-pre-wrap text-transparent dark:from-white dark:to-slate-900/10">
Confetti
</span>
<Confetti
ref={confettiRef}
className="absolute top-0 left-0 z-0 size-full"
onMouseEnter={() => {
confettiRef.current?.fire({})
}}
/>
</div>
)
}






























