Add a little bit of flair to your app with some confetti 🎊! There are no dependencies and it's tiny in size. Even better; it works without JavaScript with the help of SSR in SvelteKit (this page doesn't use SSR though)!
Click these buttons to see their effect. Most of these are not just a single toggle, they are a combination of multiple props. Don't worry we'll go over each one in the documentation further down the page!
Install using Yarn or NPM.
yarn add svelte-confetti@^2.0.0 --dev
npm install svelte-confetti@^2.0.0 --save-dev
Include the component in your app.
import { Confetti } from "svelte-confetti" <Confetti /><Confetti y={[1.25, 1.5]} x={[-1, 1]} colorArray={["#c8102e"]} />
<Confetti y={[1, 1.25]} x={[-1, 1]} colorArray={["white"]} />
<Confetti y={[0.75, 1]} x={[-1, 1]} colorArray={["#3350ec"]} />
<Confetti y={[0.75, 1.5]} x={[-1, 1]} colorArray={["#004b87"]} amount=100 />
<Confetti y={[1.05, 1.20]} x={[-1, 1]} colorArray={["#ffcd00"]} amount=50 />
<Confetti y={[0.75, 1.5]} x={[-0.5, -0.25]} colorArray={["#ffcd00"]} amount=20 />
<Confetti y={[1.20, 1.45]} x={[-0.95, -0.3]} colorArray={["white"]} size=5 />
<Confetti y={[1.45, 1.5]} x={[-0.25, 1]} colorArray={["#bf0d3e"]} amount=70 />
<Confetti y={[1.4, 1.45]} x={[-0.25, 1]} colorArray={["white"]} amount=70 />
<Confetti y={[1.35, 1.4]} x={[-0.25, 1]} colorArray={["#bf0d3e"]} amount=70 />
<Confetti y={[1.3, 1.35]} x={[-0.25, 1]} colorArray={["white"]} amount=70 />
<Confetti y={[1.25, 1.3]} x={[-0.25, 1]} colorArray={["#bf0d3e"]} amount=70 />
<Confetti y={[1.2, 1.25]} x={[-0.25, 1]} colorArray={["white"]} amount=70 />
<Confetti y={[1.15, 1.2]} x={[-0.25, 1]} colorArray={["#bf0d3e"]} amount=70 />
<Confetti y={[1.1, 1.15]} x={[-1, 1]} colorArray={["white"]} amount=70 />
<Confetti y={[1.05, 1.1]} x={[-1, 1]} colorArray={["#bf0d3e"]} amount=70 />
<Confetti y={[1, 1.05]} x={[-1, 1]} colorArray={["white"]} amount=70 />
<Confetti y={[0.95, 1]} x={[-1, 1]} colorArray={["#bf0d3e"]} amount=70 />
<Confetti y={[0.9, 0.95]} x={[-1, 1]} colorArray={["white"]} amount=70 />
<Confetti y={[0.85, 0.9]} x={[-1, 1]} colorArray={["#bf0d3e"]} amount=70 />
<div style="
position: fixed;
top: -50px;
left: 0;
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
overflow: hidden;
pointer-events: none;">
<Confetti x={[-5, 5]} y={[0, 0.1]} delay={[500, 2000]} infinite duration=5000 amount=200 fallDistance="100vh" />
</div>100vh so they cover the entire screen. :global(.confetti) and change the animation using animation-name, all values are set as css variables so you can easily use them yourself.This is a list of all configurable properties.
size 10 x [-0.5, 0.5] y [0.25, 1] duration 2000 infinite false delay [0, 50] colorRange [0, 360] colorArray [] amount 50 iterationCount 1 fallDistance "100px" rounded false cone false noGravity false xSpread 0.15 destroyOnComplete true disableForReducedMotion false