Skip to content

shadcn.io is an independent project built on shadcn/ui

Pro

Confetti Background for Solid

Paper confetti that tumbles, sways and falls in depth, with a burst on press. For Solid with Ark UI, when a launch or a milestone should feel festive.

On this page10 sections
UI library: Ark UI

Paper confetti falls through the box: small rectangles that sway, rock and flip, so each one thins to a line edge-on and flashes as its face turns to the light. It's a GLSL scene on WebGL2 with no dependency, drawn at three distances: small faint pieces far away, sharp ones in the middle, large out-of-focus ones up close. The paper keeps its colors on a light surface and a dark one. Pieces near the pointer are nudged aside, and a press throws a handful from that point.

Use it behind a launch announcement, a milestone or a success screen. In the middle of the box, where copy sits, the large near pieces drop out and the rest fade, so a headline stays readable with no props. For bursts of light on a dark page, use Fireworks; for glints that twinkle in place, Sparkles; for the same slow fall in one quiet color, Snow. With reduced motion it holds one still frame.

Playground
Confetti Background, still
Customize

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 class="flex min-h-[32rem] flex-col items-center justify-center">
  <h1 class="text-5xl font-semibold">One million invoices sent</h1>
</Confetti>

Confetti is a container: whatever you put inside sits on top of the pieces, in normal flow. It fills its own box, so give it a height or content. For a backdrop behind the whole page, render it empty with className="fixed inset-0 -z-10".

Presets

Partythe default lookTry it
<Confetti />
Driftthe default lookTry it
<Confetti
  count={90}
  depth={1}
  gravity={0.25}
  size={20}
  spin={0.5}
  sway={0.5}
/>
PetalsTry it
<Confetti
  angle={24}
  colors={["#ff9ebb", "#ff7aa2", "#ffc2d4"]}
  count={150}
  gravity={0.6}
  roundness={0.9}
  shine={0.1}
  size={15}
  spin={0.6}
  stretch={0.35}
  sway={1.8}
/>
SequinsTry it
<Confetti
  colors={["#f2b632", "#e2912a", "#f7d774"]}
  count={220}
  roundness={1}
  shine={1}
  size={10}
  stretch={0}
  sway={0.6}
/>
Stormthe default lookTry it
<Confetti
  angle={38}
  count={260}
  depth={0.9}
  gravity={1.8}
  size={11}
  sway={0.6}
/>
Streamersthe default lookTry it
<Confetti
  count={90}
  roundness={0.3}
  size={24}
  spin={0.7}
  stretch={1}
  sway={1.6}
/>
TickerTry it
<Confetti
  angle={-12}
  colors={["var(--foreground)", "var(--muted-foreground)"]}
  count={180}
  gravity={1.4}
  shine={0.2}
  size={20}
  stretch={1}
/>

Each preset is a set of props, so copy one and keep tuning. Party is the default. Sequins swaps the paper for small gold discs with a strong flash, Petals slows the fall and leans it into a breeze, and Ticker takes its two colors from your theme, so it's black strips on a light page and white ones on a dark page.

Examples

Hero

The copy is centered, which is where the scene clears: there the large near pieces drop out and the rest lose about half their strength (clearing, 0.5 by default), and they're at full strength again toward the edges of the box. The demo sets no props.

Preview width

Sequins

roundness={1} with stretch={0} turns every piece into a disc, and shine={1} makes each one flash white once a turn, like foil. Here they're three golds on a dark surface, smaller (size={10}) and more of them (count={220}).

Preview width

In a card

A confirmation card with the copy in the middle. count is a density, not a total, so a small box needs a higher value to look as full as a wide one: this card uses count={260} with smaller pieces, and clearing={0.8} keeps them off the two lines of text.

Preview width

Customization

Every color is a CSS color, so a theme variable works and follows a theme switch: colors={["var(--chart-1)", "var(--chart-2)", "var(--chart-3)"]}. The colors are shared out between the pieces as they are, never blended, so two colors give you exactly two kinds of paper.

The surface is the root's own background, bg-background by default; give the root another class (bg-slate-950) and the pieces sit on that. The paper covers the surface the same way on light and dark, so pick colors that stand out from yours. fade masks an edge, opacity turns the whole effect down, and grain adds film grain.

<Confetti
  class="min-h-[32rem] bg-slate-950"
  colors={["var(--chart-1)", "var(--chart-2)", "var(--chart-4)"]}
  fade="bottom"
  gravity={0.6}
/>

Performance

It's one WebGL2 canvas and one fragment shader with no noise and no ray marching. Each of the three distances is a grid of cells with at most one piece in each; a pixel looks at the nine cells around it and draws the pieces that reach it, so the cost stays the same at any count. A press adds 14 pieces for about three seconds. It draws only while it's on screen and the tab is visible, shares one frame loop with every other background on the page, and lowers its own resolution if frames run long. quality sets the render scale yourself, and paused holds the frame.

Accessibility

The confetti is decoration: it's hidden from assistive tech and lets every click through to your content. With reduced motion it draws one still frame, ignores the pointer and throws no bursts.

Keep copy in the middle of the box, where the pieces fade, and use the foreground color (text-foreground) for it. With the default clearing, the worst case is white text over an amber piece as it flashes on a dark surface, at about 4.6:1; on a light surface dark text stays above 5:1 over any piece of the default palette. With clearing={0} a bright piece can pass behind a word at full strength, so raise it again or keep text off the scene. A piece flashes once per turn, every two to four seconds at the default spin, and each flash is the size of the piece; nothing flashes across the box.

FAQ

How do I change the colors?

Pass two to eight CSS colors to colors. Each piece takes one of them as it is, so the list is the set of papers in the mix. Hex, oklch() and theme variables such as var(--primary) all work, and a variable follows your theme when it changes. For foil instead of matte paper, raise shine.

Does it work on a light page and a dark page?

Yes, with no prop to set. The pieces are drawn as paper, so they cover the surface the same way on white and on near-black, and the default palette (rose, amber, mint and blue) stands out on both. Set the surface with a class on the component, such as bg-slate-950.

Why are the pieces faint in the middle?

That's clearing, 0.5 by default. In a zone the size of a headline and its buttons, in the middle of the box, the large near pieces drop out and the rest lose about half their strength, so text over them stays readable. A burst thrown from inside the zone is faded the same way until its pieces leave it. Set clearing={0} for confetti at full strength everywhere, or clearing={1} to keep the middle empty.

Can I fire a burst when something happens?

A press anywhere on the background throws 14 pieces from that point; presses on links, buttons and fields inside it don't. There is no prop to fire one from code: the scene is an ambient fall. For a burst tied to one action, such as a submit, use the Confetti Button.

How do I put it behind the whole page?

Render it empty with className="fixed inset-0 -z-10". It still answers the pointer there, since it listens on the window. To put it behind one section, wrap that section's content in it and give it a height, such as min-h-svh.

Will it slow my page down?

It's a light shader: a few dozen cheap lookups a pixel, on the GPU, with the same cost at 30 pieces as at 300, and nothing at all while it's off screen or the tab is hidden. If a device can't keep up, it renders fewer pixels by itself. For a phone-first page, quality={0.75} draws a little over half the pixels and is hard to tell apart.

Does it work with Next.js and server components?

Yes. Import it into a server component and it renders its box and your content on the server; the canvas starts in the browser and fades in over the surface. It needs WebGL2, which every current browser has. Without it the box keeps its background, or the fallback you pass.

What happens with reduced motion?

It draws one still frame of the fall and stops: nothing moves, the pointer nudges nothing and a press throws no burst. The frame is the same one every time, so the page looks the same on each visit. Touch never moves the pieces either, so scrolling on a phone isn't disturbed.

API Reference

Confetti

data-slot="confetti"

PropType
angle?number

Which way the pieces drift as they fall, in degrees from -60 to 60: 0 is straight down, a positive angle leans the fall to the right.

Default
0
clearing?number

How much the pieces fade in the middle of the box, where copy sits, from 0 (they cross it at full strength) to 1 (the middle stays empty).

Default
0.5
colors?string[]

Two to eight CSS colors, shared out between the pieces. Theme variables such as var(--primary) follow your theme.

Default
["#ff4f7b", "#ffb938", "#2fc7ad", "#4f7dff"]
count?number

About how many pieces a 1280 by 720 box shows, from 30 to 300. A smaller box shows fewer, at the same spacing.

Default
140
depth?number

How deep the fall looks, from 0 (every piece the same size and sharp) to 1 (small faint pieces far away, large out-of-focus ones up close).

Default
0.7
fade?"none" | "radial" | "top" | "bottom" | "left" | "right"

Which edges fade out to the surface: radial keeps the middle, the others name the side that fades.

Type
"none" | "radial" | "top" | "bottom" | "left" | "right"
Default
"none"
fallback?string

What shows until the first frame and in browsers without WebGL2: a CSS background value that looks like the scene.

grain?number

Film grain over the scene, from 0 to 1.

Default
0
gravity?number

How fast the pieces fall, from 0 (they hang in the air) to 2.

Default
1
interactive?boolean

Whether the scene follows the pointer and answers a press. Touch never moves it, so scrolling a page on a phone isn't disturbed.

Default
true
opacity?number

How strongly the scene shows over the surface, from 0 to 1.

Default
1
paused?boolean

Holds the current frame.

Default
false
quality?number

Render scale, from 0.25 to 1, of the screen's pixels (capped at 2×). Lower is cheaper and softer.

Default
1
roundness?number

How round the corners are, from 0 (cut paper) to 1 (discs and pills).

Default
0.15
seed?number

Another layout of the same look, from 0 to 20.

Default
0
shine?number

How strongly a piece flashes as its face turns to the light, from 0 (matte paper) to 1 (foil).

Default
0.5
size?number

The long side of a piece in the middle distance, in pixels, from 6 to 28.

Default
15
speed?number

Animation speed: 1 is normal, 0 holds the frame.

Default
1
spin?number

How fast the pieces tumble, from 0 (each keeps its tilt) to 2.

Default
1
stretch?number

How long the pieces are, from 0 (every one a square) to 1 (a mix that runs to thin strips).

Default
0.6
sway?number

How far the pieces swing from side to side as they fall, from 0 to 2.

Default
1
time?number

A fixed moment, in seconds: draws it and doesn't animate.