Category · Background Effects Difficulty Level · Advanced Published on · January 21, 2024

Particle Background Animation

Interactive particle system with mouse tracking, gravity effects, and customizable configurations. Perfect for hero sections and landing pages.

#particles #animation #interactive #background #mouse-tracking

Responsive Design

Yes

Dark Mode Support

No

lines

277

Browser Compatibility

No

Live Preview

Interact with the component without leaving the page.

400px

Particle Background Animation

An interactive particle system with mouse tracking, gravity effects, and customizable color schemes. Perfect for creating engaging hero sections and dynamic backgrounds.

Features

  • Mouse Interaction: Particles respond to mouse movement with realistic physics
  • Gravity Toggle: Switch between floating and gravity-affected particle behavior
  • Color Schemes: Multiple predefined color palettes for different moods
  • Connection Lines: Dynamic lines connect nearby particles
  • Responsive Design: Adapts to different screen sizes
  • Performance Optimized: Efficient rendering with requestAnimationFrame

Usage

The particle system automatically initializes when the page loads. Use the control buttons to:

  • Reset: Regenerate all particles with new positions
  • Toggle Gravity: Enable/disable gravitational pull
  • Change Colors: Cycle through different color schemes

Customization

You can customize the particle system by modifying:

  • particleCount: Number of particles (calculated based on canvas size)
  • mouse.radius: Interaction radius around the mouse cursor
  • colorSchemes: Array of color palettes
  • Connection distance threshold for drawing lines between particles

Perfect for modern websites, landing pages, and interactive backgrounds that need a touch of dynamic visual appeal.

HTML

12

lines

CSS

95

lines

JavaScript

170

lines


                <div class="particle-demo">
  <canvas id="particleCanvas"></canvas>
  <div class="particle-overlay">
    <h1>Interactive Particle System</h1>
    <p>Move your mouse to interact with particles</p>
    <div class="particle-controls">
      <button id="resetBtn">Reset</button>
      <button id="gravityBtn">Toggle Gravity</button>
      <button id="colorBtn">Change Colors</button>
    </div>
  </div>
</div>

              
12lines
407characters
HTMLLanguage

Related Code Snippets

Explore template packs

Need larger building blocks? Browse responsive landing pages and component bundles.

Open HTML Template Library →