🎅 Ship faster with premium components 🎅
Search documentation v1.2.0

Confetti

Display falling or flying particles

Source Report Issue
Command docs
How to add this block to your project
npm run add Confetti

Use the Confetti component to display falling or flying particles, shapes or emojis. They can be used to create fun, celebratory animations that enhance user satisfaction and make success moments feel special, with full control over style and physics for tailored experiences.

Preview
Unlock code
How to use the Confetti component in Astro
<Confetti />

The Confetti component can be used as-is, without any props. The canvas will take up 100% of its container. To improve page performance, it’ll only play when the element is in viewport. You can use props to change colors, shapes and physics.

Presets

The component comes with 33 presets (including holiday-specific particle effects such as Christmas, New Year or Easter) that you can pass to the component to quickly achieve certain effects. For example, weather conditions or flying particles:

Blizzard
Flying confetti
Rain
Unlock code
How to use presets
---
import { confettiPresets } from '@components/Confetti/presets'
---
<Confetti {...confettiPresets.blizzard} />
Unlock code
How to use presets
---
import { confettiPresets } from '@components/Confetti/presets'
---
<Confetti {...confettiPresets.flyingConfetti} />
Unlock code
How to use presets
---
import { confettiPresets } from '@components/Confetti/presets'
---
<Confetti {...confettiPresets.rain} />

Colors and Opacity

The colors and opacity of the particles can be configured using the colors and opacity props. The colors prop expects an array of colors. If you need all particles to have the same color, simply pass a single color to the array.

The opacity prop expect a number between 0.1 and 1. If the opacity prop is not provided, each particle will receive a random opacity based on its size, otherwise all particles will have the same opacity.

Custom colors
Unlock code
How to set custom particle colors
<Confetti colors={[
'#f8db00',
'#ff9f43',
'#de3233'
]} />

Shapes

The shapes of the particles can also be customized using the shapes prop that expects an array of strings. It can have the following values: circle, square, triangle and star. For example, if you want to display circles only, you can use the following:

Circles only
Unlock code
How to set customize shapes
<Confetti shapes={['circle']} />

If the shapes prop is omitted, the component will use all available shapes.

Emojis

In case you want to use custom shapes, you can use the emoji prop to pass text or emojis. If the prop is set, it’ll take priority over the shapes prop:

Using custom emojis
Unlock code
How to use emojis and text
<Confetti emojis={['', '']} />

Physics

The physics of the particles can be configured through the following props:

For example, to simulate slow falling snow, you can modify physics props as per the following:

Unlock code
How to modify physics. More examples can be found in the provided presets.
<Confetti
amount={150}
gravity={0.008}
terminalVelocity={1.5}
turbulence={0}
shapes={['circle']}
colors={['#FFFFFF', '#F0F8FF', '#E6F3FF']}
size={0.1}
speed={0.8}
/>

API

Unlock code
Component API reference
type ConfettiProps = {
amount?: number
colors?: string[]
shapes?: ('circle' | 'square' | 'triangle' | 'star')[]
emojis?: string[]
gravity?: number
airResistance?: number
terminalVelocity?: number
wind?: number
turbulence?: number
speed?: number
size?: number
opacity?: number
wanderFrequency?: number
wanderAmplitude?: number
className?: string
}
PropDefaultPurpose
amount 200 Sets the number of confetti particles to create.
colors [] Sets an array of colors particles can randomly use. Defaults to an internal palette.
shapes [] Sets the shapes particles can randomly be assigned. Defaults to all shapes.
emojis [] Sets an optional list of emojis to use instead of shapes.
gravity 0.05 Sets the vertical downward acceleration applied to particles.
airResistance 0.99 Multiplier reducing velocity each tick to simulate air drag.
terminalVelocity 8 Sets the maximum downward speed allowed for particles.
wind 0 Sets a constant horizontal wind force applied to all particles.
turbulence 0.3 Sets a random jitter added to movement to simulate chaotic air currents.
speed 1 Sets the global speed multiplier affecting all movement.
size 1 Sets a base particle size. The final size is slightly randomized.
opacity - Sets a fixed particle opacity. If omitted, opacity is auto-computed based on size.
wanderFrequency 5000 Controls how often horizontal wandering oscillation occurs.
wanderAmplitude 0.3 Sets the strength of horizontal wandering movement.
className - Pass additional CSS classes for the component that will be added to the canvas.