🎉 JavaScript Confetti library
✅ Zero dependencies used
✅ Works without any config
✅ Has TypeScript typings
✅ Confetti speed adapts to user screen width
Demo: https://loonywizard.github.io/js-confetti/
Usage
Install library via yarn or npm
yarn add js-confetti
Initialize instance of JSConfetti class and call addConfetti method
import JSConfetti from 'js-confetti'
const jsConfetti = new JSConfetti()
jsConfetti.addConfetti()
addConfetti args
addConfetti
method accepts args object with the following params:
Prop | Type | Description | Default value |
---|
confettiRadius | number | Radius of confetti shape in pixels | 8 |
confettiesNumber | number | Number of confetties to fire | 200 |
confettiColors | string[] | Array of colors for confetti | Array of RGB colors |
jsConfetti.addConfetti({
confettiRadius: 8,
confettiesNumber: 200,
confettiColors: ['#fcf403', '#62fc03', '#f4fc03', '#03e7fc', '#03fca5', '#a503fc', '#fc03ad', '#fc9003']
})