Home

Awesome

react-particle-animation (demo)

✨ Canvas-based particle animation for React.

NPM Build Status JavaScript Style Guide

Install

npm install --save react-particle-animation
# or
yarn add react-particle-animation

Usage

Check out the demo in the example folder.

import React, { Component } from 'react'

import ParticleAnimation from 'react-particle-animation'

class Example extends Component {
  render () {
    return (
      <ParticleAnimation />
    )
  }
}

Props

PropertyTypeDefaultDescription
numParticlesnumber400Number of particles to use.
interactivebooleantrueWhether or not animation responds to mouse hover.
colorobject{ r: 158, g: 217, b: 249, a: 255 }Base rgba particle color.
backgroundobject{ r: 255, g: 255, b: 255, a: 255 }Background rgba color.
lineWidthnumber1.0Connecting line width.
particleRadiusnumber1.0Scaling factor for particle radii.
particleSpeednumber1.0Scaling factor for particle speed.
......undefinedAny other props are applied to the root canvas element.

Note that for colors, rgba are all floating point numbers between 0 and 255 (inclusive).

Note that the canvas size will automatically be inferred based on available space via react-sizeme, so it should be really easy to use this component as a fullscreen background as in the demo.

Related

License

MIT © transitive-bullshit

This module was bootstrapped with create-react-library.

Support my OSS work by <a href="https://twitter.com/transitive_bs">following me on twitter <img src="https://storage.googleapis.com/saasify-assets/twitter-logo.svg" alt="twitter" height="24px" align="center"></a>