Command Palette

Search for a command to run...

Docs
Spark Rain

Spark Rain

Dynamic falling beam background with collision-driven spark particles

Spark Rain

Dynamic beams with collision-driven particles

Installation

Usage

import { SparkRain } from "@/components/motionx/spark-rain";

Basic usage

<div className="h-[500px] w-full">
  <SparkRain className="bg-background">
    <h1 className="relative z-10 text-4xl font-bold">Your Content</h1>
  </SparkRain>
</div>

Custom colors

<SparkRain
  beamColor="from-emerald-400 via-emerald-400/60 to-transparent"
  sparkColor="from-emerald-400 to-emerald-400/60"
  beamCount={20}
  sparkCount={20}
  className="bg-background"
>
  <h1 className="relative z-10 text-4xl font-bold">Matrix Rain</h1>
</SparkRain>

Minimal, slow beams

<SparkRain
  beamCount={8}
  sparkCount={8}
  minDuration={6}
  maxDuration={12}
  className="bg-background"
>
  <p className="relative z-10 text-muted-foreground">Subtle background</p>
</SparkRain>

Props

PropTypeDefaultDescription
childrenReactNodeContent rendered on top of the effect
classNamestringContainer CSS classes (set background here)
beamCountnumber14Number of falling beams
beamColorstring"from-indigo-500 via-purple-500 to-transparent"Tailwind gradient classes for beams
sparkColorstring"from-indigo-500 to-purple-500"Tailwind gradient classes for collision sparks
sparkCountnumber16Number of particles per collision
minDurationnumber3Minimum beam fall duration in seconds
maxDurationnumber8Maximum beam fall duration in seconds

Note: Beams are dynamically positioned based on container width using ResizeObserver. The component fills 100% of its parent — set explicit height on the wrapper.