✨ A comprehensive React package for stunning animated backgrounds with interactive controls, themes, performance monitoring, and layered compositions.
Major upgrade with powerful new features:
- Mouse & Touch Interactions: 8 interaction effects (attract, repel, follow, burst, gravity, magnetic, vortex, wave)
- Multi-touch Support: Responsive mobile gestures and interactions
- Real-time Force Simulation: Physics-based particle interactions
- 8 Predefined Themes: Gaming, Portfolio, Landing, Presentation, Wellness, Party, Cyberpunk, Retro
- Custom Color Schemes: Dynamic color management and gradients
- Theme-aware Animations: Automatic color and style adaptation
- Animation Controls: Play/pause/reset functionality with speed control (0.1x-5.0x)
- Performance Monitoring: Real-time FPS tracking and memory usage
- Adaptive Optimization: Automatic performance adjustments
- Multiple Animation Layers: Composite animations with individual opacity and blend modes
- Independent Controls: Per-layer speed and timing control
- Advanced Blend Modes: 16 CSS blend modes for stunning visual effects
npm install animated-backgrounds
import { AnimatedBackground } from 'animated-backgrounds';
function App() {
return (
<div>
<AnimatedBackground animationName="particleNetwork" />
<h1>Your content here</h1>
</div>
);
}
import { AnimatedBackground } from 'animated-backgrounds';
function App() {
return (
<AnimatedBackground
animationName="particleNetwork"
theme="cyberpunk"
interactive={true}
interactionConfig={{
effect: 'attract',
strength: 0.8,
radius: 150,
continuous: true
}}
/>
);
}
import { AnimatedBackground, useAnimationControls } from 'animated-backgrounds';
function App() {
const controls = useAnimationControls();
return (
<div>
<AnimatedBackground
animationName="starryNight"
animationControls={controls}
/>
<div className="controls">
<button onClick={controls.play}>Play</button>
<button onClick={controls.pause}>Pause</button>
<button onClick={() => controls.setSpeed(2.0)}>2x Speed</button>
</div>
</div>
);
}
import { AnimatedBackground, usePerformanceMonitor } from 'animated-backgrounds';
function App() {
const performance = usePerformanceMonitor();
return (
<div>
<AnimatedBackground
animationName="matrixRain"
enablePerformanceMonitoring={true}
adaptivePerformance={true}
/>
<div className="performance-info">
FPS: {performance.fps} | Level: {performance.performanceLevel}
</div>
</div>
);
}
import { LayeredBackground } from 'animated-backgrounds';
function App() {
const layers = [
{ animation: 'starryNight', opacity: 0.8, blendMode: 'normal', speed: 0.5 },
{ animation: 'cosmicDust', opacity: 0.6, blendMode: 'screen', speed: 1.0 },
{ animation: 'auroraBorealis', opacity: 0.4, blendMode: 'overlay', speed: 1.5 }
];
return (
<LayeredBackground layers={layers} />
);
}
particleNetwork
- Interactive particle system with connectionsstarryNight
- Twinkling stars with smooth movementfloatingBubbles
- Gentle bubbles with realistic physicsgradientWave
- Dynamic flowing gradient wavesgeometricShapes
- Rotating geometric patternsmatrixRain
- Digital rain effectauroraBorealis
- Northern lights simulation
fireflies
- Glowing fireflies in the forestoceanWaves
- Realistic ocean wave simulationautumnLeaves
- Falling autumn leavessnowFall
- Gentle snowfall effect
galaxySpiral
- Spinning galaxy animationelectricStorm
- Lightning and electrical effectscosmicDust
- Cosmic particle fieldquantumField
- Quantum physics visualizationneonPulse
- Pulsing neon lightsdnaHelix
- DNA double helix rotation
<AnimatedBackground
animationName="particleNetwork"
theme="cyberpunk" // gaming, portfolio, landing, presentation, wellness, party, cyberpunk, retro
/>
gaming
- High-contrast gaming aestheticportfolio
- Professional and cleanlanding
- Modern landing page stylepresentation
- Business presentation readywellness
- Calm and soothing colorsparty
- Vibrant and energeticcyberpunk
- Neon and futuristicretro
- Nostalgic color schemes
const interactionConfig = {
effect: 'attract', // 'attract' | 'repel' | 'follow' | 'burst' | 'gravity' | 'magnetic' | 'vortex' | 'wave'
strength: 0.8, // 0.1 to 2.0
radius: 150, // pixels
continuous: true, // continue effect after mouse leaves
multiTouch: true // enable multi-touch for mobile
};
<AnimatedBackground
interactive={true}
interactionConfig={interactionConfig}
/>
attract
- Particles are drawn toward cursorrepel
- Particles push away from cursorfollow
- Particles trail behind cursor movementburst
- Explosive effect on interactiongravity
- Realistic gravitational pullmagnetic
- Magnetic field interactionvortex
- Spinning vortex effectwave
- Ripple wave propagation
import { useAnimationControls } from 'animated-backgrounds';
const controls = useAnimationControls();
// Available methods:
controls.play(); // Start animation
controls.pause(); // Pause animation
controls.reset(); // Reset to initial state
controls.toggle(); // Toggle play/pause
controls.setSpeed(1.5); // Set speed (0.1x to 5.0x)
// Available properties:
controls.isPlaying; // Current play state
controls.speed; // Current speed multiplier
import { usePerformanceMonitor } from 'animated-backgrounds';
const performance = usePerformanceMonitor();
// Available metrics:
performance.fps; // Current FPS
performance.avgFps; // Average FPS
performance.performanceLevel; // 'excellent' | 'good' | 'fair' | 'poor'
performance.memoryUsage; // Memory usage info
performance.frameTime; // Frame render time
Create complex visual compositions by layering multiple animations:
import { LayeredBackground } from 'animated-backgrounds';
const cosmicScene = [
{
animation: 'starryNight',
opacity: 0.8,
blendMode: 'normal',
speed: 0.3
},
{
animation: 'cosmicDust',
opacity: 0.6,
blendMode: 'screen',
speed: 0.8
},
{
animation: 'auroraBorealis',
opacity: 0.4,
blendMode: 'overlay',
speed: 1.2
}
];
<LayeredBackground layers={cosmicScene} />
normal
, multiply
, screen
, overlay
, darken
, lighten
, color-dodge
, color-burn
, hard-light
, soft-light
, difference
, exclusion
, hue
, saturation
, color
, luminosity
Prop | Type | Default | Description |
---|---|---|---|
animationName |
string |
'geometricShapes' |
Name of the animation |
theme |
string |
undefined |
Theme name for colors |
interactive |
boolean |
false |
Enable mouse/touch interactions |
interactionConfig |
object |
{} |
Interaction configuration |
animationControls |
object |
undefined |
External animation controls |
enablePerformanceMonitoring |
boolean |
false |
Enable performance tracking |
adaptivePerformance |
boolean |
false |
Auto-optimize performance |
fps |
number |
60 |
Target frames per second |
blendMode |
string |
'normal' |
Canvas blend mode |
style |
object |
{} |
Custom CSS styles |
Property | Type | Default | Description |
---|---|---|---|
effect |
string |
'attract' |
Interaction effect type |
strength |
number |
0.5 |
Effect strength (0.1-2.0) |
radius |
number |
100 |
Interaction radius in pixels |
continuous |
boolean |
true |
Continue after mouse leaves |
multiTouch |
boolean |
false |
Enable multi-touch support |
<AnimatedBackground
animationName="electricStorm"
theme="gaming"
interactive={true}
interactionConfig={{
effect: 'burst',
strength: 1.2,
radius: 200
}}
adaptivePerformance={true}
/>
<AnimatedBackground
animationName="geometricShapes"
theme="portfolio"
fps={30}
style={{ opacity: 0.6 }}
/>
<AnimatedBackground
animationName="floatingBubbles"
theme="wellness"
interactive={true}
interactionConfig={{
effect: 'follow',
strength: 0.6,
multiTouch: true
}}
adaptivePerformance={true}
fps={30}
/>
Problem: Particles don't respond to mouse movement
Solution: Ensure interactive={true}
and check that the canvas doesn't have pointer-events: none
// Correct usage
<AnimatedBackground
interactive={true}
style={{ pointerEvents: 'auto' }} // Ensure pointer events are enabled
/>
Problem: Low FPS or choppy animations Solutions:
- Enable adaptive performance:
adaptivePerformance={true}
- Reduce FPS:
fps={30}
- Use simpler animations for mobile devices
Problem: Theme doesn't change animation colors Solution: Ensure the animation supports themes (check documentation)
// Some animations support themes better than others
<AnimatedBackground
animationName="particleNetwork" // Good theme support
theme="cyberpunk"
/>
- Mobile Devices: Use
fps={30}
andadaptivePerformance={true}
- Low-end Hardware: Stick to basic animations like
starryNight
orgeometricShapes
- Background Usage: Consider using
style={{ opacity: 0.6 }}
for better text readability
- Live Demo - Interactive examples
- API Documentation - Complete API reference
- GitHub Repository - Source code
We welcome contributions! Please see our Contributing Guide for details.
MIT License - see LICENSE file for details.
- Node.js: 16.x or higher
- React: 16.8 or higher (hooks support required)
- Browsers: Modern browsers with Canvas support
- TypeScript: Full TypeScript definitions included
Made with ❤️ by Umer Farooq
npm install animated-backgrounds