Background

Fireworks Background

Interactive canvas-based fireworks animation with customizable particles and click-to-launch functionality. Perfect for React applications requiring celebratory backgrounds with Next.js integration and TypeScript support.

Powered by

Loading component...

Installation

npx shadcn@latest add https://www.shadcn.io/registry/fireworks-background.json
npx shadcn@latest add https://www.shadcn.io/registry/fireworks-background.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/fireworks-background.json
bunx shadcn@latest add https://www.shadcn.io/registry/fireworks-background.json

Features

  • Canvas-based animations with smooth particle physics and realistic firework trajectories
  • Interactive click-to-launch allowing users to create fireworks by clicking anywhere on the canvas
  • Customizable parameters including population density, colors, speeds, and particle sizes
  • Automatic launching with configurable timing and random positioning for continuous displays
  • TypeScript support with complete interface definitions and flexible configuration options
  • shadcn/ui compatibility using utility classes and responsive design patterns

Examples

High Population

Loading component...

Demonstrates increased firework frequency with higher population setting.

Variable Sizes and Speeds

Loading component...

Shows customizable size and speed ranges for more dynamic effects.

Fixed Parameters

Loading component...

Uses consistent sizing and speed values for uniform firework patterns.

Use Cases

This free open source React component works well for:

  • Celebration pages - New Year, achievements, and milestone backgrounds built with Next.js
  • Event websites - Festival and party themes using TypeScript and Tailwind CSS
  • Gaming interfaces - Victory screens and achievement unlocks with interactive elements
  • Marketing campaigns - Product launches and promotional backgrounds

API Reference

FireworksBackground

PropTypeDefaultDescription
populationnumber1Controls firework launch frequency (higher = more frequent)
colorstring | string[]randColor()Single color or array of colors for fireworks
fireworkSpeed{min: number, max: number} | number{min: 4, max: 8}Launch speed range or fixed speed
fireworkSize{min: number, max: number} | number{min: 2, max: 5}Firework trail thickness range or fixed size
particleSpeed{min: number, max: number} | number{min: 2, max: 7}Explosion particle speed range or fixed speed
particleSize{min: number, max: number} | number{min: 1, max: 5}Explosion particle size range or fixed size
canvasPropsReact.ComponentProps<'canvas'>-Additional props passed to the canvas element

Configuration Options

  • Range values - Use {min: number, max: number} for randomized effects
  • Fixed values - Use number for consistent, uniform appearance
  • Colors - Support single strings, arrays of colors, or automatic random colors

Implementation Notes

  • Canvas automatically resizes to match container dimensions
  • Physics simulation includes gravity, friction, and particle decay
  • Click handling launches fireworks toward cursor position
  • Automatic cleanup prevents memory leaks during component unmount
  • Compatible with shadcn/ui theming and responsive layouts
  • Optimized performance with requestAnimationFrame animations