Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Backgrounds

Pro

Confetti Background for React

Confetti drifting slowly down behind your content, each piece swaying and flipping in 3D and catching the light. For React with Base UI, when a launch, a success page or a celebration should feel festive without a burst.

Framework

Confetti drifts slowly down behind your content: strips, squares, dots, chips and streamers in rose, coral, gold, teal and periwinkle. Each piece falls, sways and flips over in 3D on its own timing, and its face is lit at one corner and shaded at the other, so it catches the light as it turns and darkens edge-on. Far pieces are half the size of near ones, fainter and slower, which gives the fall depth, and a narrower box gets fewer pieces, so a phone looks as full as a desktop. The pieces are placed from their index when the page renders and moved by CSS keyframes, so no script runs and nothing speeds up as it falls. It's an ambient background; for a burst when someone clicks, use the confetti button.

Use it for launches, success pages and celebrations. For bursts that explode and fade use Fireworks; for glitter that twinkles in place, Sparkles; for the same fall in white, Snow; for soft colour discs that drift instead, Bokeh.

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Usage

import { Confetti } from "@/components/ui/confetti";
<Confetti className="min-h-[420px]">
  <h1>We just launched</h1>
</Confetti>

Confetti is a container: put your content inside and the confetti falls behind it. It fills the box you give it, so set its height (min-h-[420px]), or className="fixed inset-0 -z-10" to cover the whole page.

Demos

Brand colours

colors takes any CSS colours, shared out among the pieces. Theme variables such as var(--primary) work too.

Preview width

Inside a card

A card with slower pieces (speed={0.7}). count={60} is for a wide box: in a card this narrow about a third of them fall, some 21. The pieces fall at the same pace in a card as on a full page.

Preview width

Accessibility

The confetti is decoration: the whole layer is hidden from screen readers and ignores the pointer, and your content inside reads as usual. With reduced motion every piece stops where it is, mid-flip, so the box shows a still scatter of confetti. Nothing flashes: the shading changes as a piece turns, over a second or more.

The colours are saturated and can cross your headline's letters: keep text in the foreground colour, and lower count behind body text.

FAQ

Why doesn't it burst?

It's an ambient background that falls evenly the whole time. For a burst from a click, use the confetti button.

Can I use my brand colours?

Pass colors: the pieces share them out, and theme variables like var(--primary) work. The default party palette is also set by the --confetti-color-1 to --confetti-color-5 variables, so you can change one colour from CSS.

How much confetti?

count is how many pieces fall at once in a wide box, 64 by default and at most 120. A narrower box shows fewer: 70% under 1080 px wide, half under 720 and 35% under 480, so a phone looks about as full as a desktop. Lower it behind body text.

Can I make it faster or slower?

speed scales the fall, the sway and the flip together: 0.5 is very calm, 2 is lively. The pieces fall at a set number of pixels per second, so a small card and a full page look the same.

How do the pieces flip and catch the light?

Each piece turns about its own tilted axis with a CSS 3D rotation while it sways and falls, so it shows face-on, foreshortened and edge-on in turn. Its face is a gradient, lighter at one corner and darker at the other, so the shading shifts as it turns. No physics runs in the browser.

Does it respect reduced motion?

Yes: the pieces stop where they are, at assorted tilts. Nothing flashes.

API Reference

Confetti

<div> data-slot="confetti"

PropType
colors?string[]

The pieces' colours, any CSS colours, spread over the pieces. By default a party palette of rose, coral, gold, teal and periwinkle; theme variables such as var(--primary) work too.

count?number

How many pieces fall at once in a wide box, from 0 to 120. A narrower box shows fewer (70% under 1080 px wide, half under 720, 35% under 480), so a phone looks as full as a desktop.

Default
64
speed?number

How fast the pieces fall, sway and flip, as a multiplier: 0.5 is very calm, 2 is lively.

Default
1
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

CSS variableType
--confetti-color-1string

The first palette colour (rose); -2 to -5 are coral, gold, teal and periwinkle.

--confetti-speedstring

How fast the pieces fall, sway and flip, a multiplier (1).

All 100 backgrounds