Confetti

A Vue component for confetti animations.

Install using CLI

npm
pnpm
bun
yarn
npx shadcn-vue@latest add "https://inspira-ui.com/r/confetti.json"

Install Manually

Install the dependencies

npm
pnpm
bun
yarn
npm install canvas-confetti
npm install -D @types/canvas-confetti

Copy and paste the following code

Confetti.vue
ConfettiButton.vue

Examples

Basic

Random Direction

Fireworks

Side Cannons

API

Components props

Confetti

Prop NameTypeDefaultDescription
optionsConfettiOptions{}Options for individual confetti bursts.
globalOptionsConfettiGlobalOptions{}Global options for the confetti instance (e.g., resize behavior).
manualstartbooleanfalseIf true, confetti won't start automatically on mount.

ConfettiOptions

PropertyTypeDefaultDescription
particleCountnumber50The number of confetti particles to launch.
anglenumber90The angle in degrees at which to launch the confetti.
spreadnumber45The spread in degrees of the confetti.
startVelocitynumber45The initial velocity of the confetti particles.
decaynumber0.9The rate at which confetti particles slow down.
gravitynumber1The gravity applied to confetti particles.
driftnumber0The horizontal drift applied to confetti particles.
ticksnumber200The number of animation frames the confetti should last.
origin{ x: number, y: number }{ x: 0.5, y: 0.5 }The origin point (from 0 to 1) of the confetti emission.
colorsstring[]['#26ccff', '#a25afd', '#ff5e7e', '#88ff5a', '#fcff42', '#ffa62d', '#ff36ff']Array of color strings in HEX format for the confetti particles.
shapesstring[]['square', 'circle']Array of shapes for the confetti particles.
scalarnumber1Scaling factor for confetti particle sizes.
zIndexnumber100The z-index value for the confetti canvas element.
disableForReducedMotionbooleanfalseDisables confetti for users who prefer reduced motion.
useWorkerbooleantrueUse a Web Worker for better performance.
resizebooleantrueWhether to automatically resize the canvas when the window resizes.
canvasHTMLCanvasElement | nullnullCustom canvas element to draw confetti on.
gravitynumber1The gravity applied to confetti particles.
driftnumber0The horizontal drift applied to particles.
flatbooleanfalseIf true, confetti particles will be flat (no rotation or 3D effect).

ConfettiButton

Prop NameTypeDefaultDescription
optionsConfettiOptions & { canvas?: HTMLCanvasElement }{}Options for confetti when the button is clicked.

Features

  • Confetti Animation: Easily add confetti animations to your Vue application.
  • Customizable Options: Configure both global and individual options for confetti behavior.
  • Manual Control: Choose whether to start confetti automatically or manually trigger it.
  • Button Integration: Use the ConfettiButton component to trigger confetti on button clicks.

Credits