A background component that displays a fireworks animation.
Installation
Usage
<script setup lang="ts">
import FireworksBackground from '@/components/animate-ui/backgrounds/fireworks/FireworksBackground.vue';
</script>
<template>
<section class="relative h-[480px] overflow-hidden">
<FireworksBackground class="absolute inset-0" />
</section>
</template>Examples
Fireworks Circle
Animation
- Rockets launch from the bottom edge every 300 to 800ms (divided by
population), trail upwards and burst into 50 to 150 particles that slow down, fall and fade. - A click launches a rocket towards the pointer.
- The show takes place in a space as wide as the window, with the container's aspect ratio, scaled down to the container: in a container narrower than the window, rockets and particles are smaller and slower. The canvas is drawn at the device pixel ratio.
- The simulation advances one step per displayed frame, so it runs faster on 120Hz screens.
- It pauses off screen and while the tab is hidden: nothing launches and the last frame stays.
- Under reduced motion, it shows a still frame of three bursts and clicks do nothing.
API Reference
FireworksBackground
| Prop | Type | Default |
|---|---|---|
population? | number | 1 |
color? | string | string[] | a random hue per rocket |
firework-speed? | number | { min: number; max: number } | { min: 4, max: 8 } |
firework-size? | number | { min: number; max: number } | { min: 2, max: 5 } |
particle-speed? | number | { min: number; max: number } | { min: 2, max: 7 } |
particle-size? | number | { min: number; max: number } | { min: 1, max: 5 } |
canvas-props? | CanvasHTMLAttributes | - |
...attrs? | HTMLAttributes | - |
Credits
- Credits to Matt Cannon for the inspiration