react-sparkle
Make your React app more :sparkles:sparkly:sparkles:
Demo
How to Use
Install: yarn add react-sparkle
or npm install react-sparkle
Add Sparkle
as a child of the element you want to add sparkles to. Important: the parent element must have either relative
or absolute
positioning.
import React from 'react'
import Sparkle from 'react-sparkle'
const SparklyThing = () => (
<div style={{ position: 'relative' }}>
<Sparkle />
</div>
)
Options
All props are optional. These are the defaults:
<Sparkle
color={'#FFF'}
count={50}
minSize={5}
maxSize={8}
overflowPx={20}
fadeOutSpeed={50}
newSparkleOnFadeOut={true}
flicker={true}
flickerSpeed={'normal'}
/>
Limitations
- The props only take effect on mount. If you need modified props to take effect, you need to unmount and remount
Sparkle
. - The sparkle image sprites aren't currently customizable. In the future, we might want to accept custom images or use drawn canvas shapes to eliminate the images altogether.
Acknowledgements
This code was inspired by and based on jQuery Canvas Sparkles.