Fireworks Background

A background component that displays a fireworks animation.

"use client"

import { useTheme } from "next-themes"

import { FireworksBackground } from "@/components/animate-ui/backgrounds/fireworks"

export default function FireworksBackgroundDemo({
  population = 1,
}: {
  population?: number
}) {
  const { resolvedTheme } = useTheme()

  return (
    <FireworksBackground
      className="absolute inset-0"
      color={resolvedTheme === "dark" ? "white" : "black"}
      population={population}
    />
  )
}

Installation

npx shadcn@latest add @animate-ui/backgrounds-fireworks
pnpm dlx shadcn@latest add @animate-ui/backgrounds-fireworks
yarn dlx shadcn@latest add @animate-ui/backgrounds-fireworks
bun x shadcn@latest add @animate-ui/backgrounds-fireworks

Usage

import { FireworksBackground } from '@/components/animate-ui/backgrounds/fireworks';

export function Hero() {
  return (
    <section className="relative h-[480px] overflow-hidden">
      <FireworksBackground className="absolute inset-0" />
    </section>
  );
}

Examples

Fireworks Circle

"use client"

import { useTheme } from "next-themes"

import { FireworksBackground } from "@/components/animate-ui/backgrounds/fireworks"

export default function FireworksCircleBackgroundDemo({
  population = 1,
  fireworkSize = 7,
  fireworkSpeed = 7,
  particleSize = 7,
  particleSpeed = 7,
}: {
  population?: number
  fireworkSize?: number
  fireworkSpeed?: number
  particleSize?: number
  particleSpeed?: number
}) {
  const { resolvedTheme } = useTheme()

  return (
    <FireworksBackground
      className="absolute inset-0"
      color={resolvedTheme === "dark" ? "white" : "black"}
      population={population}
      fireworkSize={fireworkSize}
      fireworkSpeed={fireworkSpeed}
      particleSize={particleSize}
      particleSpeed={particleSpeed}
    />
  )
}

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

PropTypeDefault
population?
number1
color?
string | string[]a random hue per rocket
fireworkSpeed?
number | { min: number; max: number }{ min: 4, max: 8 }
fireworkSize?
number | { min: number; max: number }{ min: 2, max: 5 }
particleSpeed?
number | { min: number; max: number }{ min: 2, max: 7 }
particleSize?
number | { min: number; max: number }{ min: 1, max: 5 }
canvasProps?
React.ComponentProps<'canvas'>-
...props?
Omit<React.ComponentProps<'div'>, 'color'>-

Credits

Built by Skyleen. The source code is available on GitHub.

Last updated: 10/18/2026

On this page