1.0.5 • Published 10 months ago

falling-particles v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Falling Particles

A simple React TypeScript component for creating falling animations (snow, confetti, etc)

Check out the demo site!

Installation

npm install falling-particles

Usage

You can use this package with the default config, or pass in a lot of customizable props.

Default

import React from "react";
import FallingParticles from "falling-particles";

const App = () => {
  return (
    <div style={{ backgroundColor: "black", width: "100vw", height: "100vh" }}>
      <FallingParticles />
    </div>
  );
};

export default App;

Custom

import React from "react";
import FallingParticles from "falling-particles";

const App = () => {
  return (
    <div style={{ backgroundColor: "black", width: "100vw", height: "100vh" }}>
      <FallingParticles
        colors={["magenta", "cyan", "yellow"]}
        numParticles={300}
        xSpeedRange={{ min: 2, max: 4 }}
        ySpeedRange={{ min: 2, max: 4 }}
        shapes={["circle", "square", "triangle"]}
        rotationRange={{ min: 1, max: 4 }}
        sizeRange={{ min: 5, max: 10 }}
      />
    </div>
  );
};

export default App;

Props

Prop NameTypeDefault ValueDescription
colorsstring[]["#fff"]An array of colors to randomly choose from for the particles.
shapesstring[]["circle"]An array of shapes to randomly choose from for the particles.
imagesstring[][]An array of image urls to randomly choose from for the particles.
numParticlesnumber120The number of particles to render.
xSpeedRangeRange{ min: -2.5, max: 2.5 }The range of x-axis speeds to randomly choose from for the particles.
ySpeedRangeRange{ min: 1.5, max: 3 }The range of y-axis speeds to randomly choose from for the particles.
rotationRangeRange{ min: 0, max: 0 }The range of rotations to randomly choose from for the particles.
sizeRangeRange{ min: 1, max: 6 }The range of sizes to randomly choose from for the particles. (Width for images, rectangles & triangles, diameter for circles)
styleReact.CSSPropertiesSee the default style configA style object to apply to the container canvas element.
classNamestringundefinedA className to apply to the container canvas element.
1.0.5

10 months ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago