Voltar ao ranking

marcbruederlin/particles.js

JavaScriptmarcbruederlin.github.io/particles.js/

A lightweight, dependency-free and responsive javascript plugin for particle backgrounds.

particlesparticle-backgroundsjavascriptvanilla-javascriptanimatedresponsive
Crescimento de estrelas
Estrelas
1.7k
Forks
209
Crescimento semanal
Issues
14
5001k1.5k
jan. de 2023mar. de 2024mai. de 2025jul. de 2026
Artefatosnpmnpm install particles.js
README

particles.js

Github file size Travis David David npm CDNJS GitHub license

particles.js is a lightweight, dependency-free and responsive javascript plugin for particle backgrounds.

Installation

There are several ways to install particles.js:

  • Download the latest version
  • Install with npm: npm install particlesjs --save
  • Use the CDN: https://cdnjs.cloudflare.com/ajax/libs/particlesjs/2.2.3/particles.min.js

Usage

Include the minified JS in your HTML (right before the closing body tag).

<body>
  …
  <script src="path/to/particles.min.js"></script>
</body>

Add a canvas element to your markup (it should be the last element)

<body>
  …
  <canvas class="background"></canvas>
  <script src="path/to/particles.min.js"></script>
</body>

Add a few styles to your css.

html,
body {
  margin: 0;
  padding: 0;
}

.background {
  position: absolute;
  display: block;
  top: 0;
  left: 0;
  z-index: 0;
}

Initialize the plugin on the window.onload event.

window.onload = function() {
  Particles.init({
    selector: '.background'
  });
};

Options

Option Type Default Description
selector string - Required: The CSS selector of your canvas element
maxParticles integer 100 Optional: Maximum amount of particles
sizeVariations integer 3 Optional: Amount of size variations
speed integer 0.5 Optional: Movement speed of the particles
color string or string[] #000000 Optional: Color(s) of the particles and connecting lines
minDistance integer 120 Optional: Distance in px for connecting lines
connectParticles boolean false Optional: true/false if connecting lines should be drawn or not
responsive array null Optional: Array of objects containing breakpoints and options

Example how to use the responsive option.

Methods

Method Description
pauseAnimation Pauses/stops the particle animation
resumeAnimation Continues the particle animation
destroy Destroys the plugin

Example how to use the public methods.

Browser Support

IE9+ and all modern browsers.

Examples

See various examples how you can use particles.js.

Build

To compile the distribution files by yourself, make sure that you have node.js and gulp installed, then:

  • Clone the repository: https://github.com/marcbruederlin/particles.js.git
  • Change in the project directory: cd particles.js
  • Install the dependencies: npm install
  • Run the gulp build task gulp build to regenerate the dist folder.
    You can also run gulp build --watch to watch for file changes and automatically rebuild the files.

Using particles.js?

If you’re using particles.js in some interesting way or on a cool site, I’d be very grateful if you shoot me a link to it.
For any problems or questions don't hesitate to open an issue.

License

particles.js is created by Marc Brüderlin and released under the MIT license.

Version 1.x

The source code for particles.js 1.x has been moved to the v1 branch.

Repositórios relacionados
catdad/canvas-confetti

🎉 performant confetti animation in the browser

JavaScriptnpmISC Licensecanvasconfetti
catdad.github.io/canvas-confetti/
12.7k466
tsparticles/tsparticles

tsParticles - Easily create highly customizable JavaScript particles effects, confetti explosions and fireworks animations and use them as animated backgrounds for your website. Ready to use components available for React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Solid, Riot and Web Components.

TypeScriptnpmMIT Licenseparticlestypescript
particles.js.org
8.9k948
michidk/Unity-Script-Collection

A maintained collection of useful & free unity scripts / library's / plugins and extensions

GNU General Public License v3.0unity-scriptsunity
michidk.github.io/Unity-Script-Collection/
6.3k652
hustcc/canvas-nest.js

:cancer: Interactive Particle / Nest System With JavaScript and Canvas, no jQuery.

JavaScriptnpmMIT Licensecanvascanvas-nest
git.hust.cc/canvas-nest.js
4.3k809
EmergeTools/Pow

Delightful SwiftUI effects for your app

SwiftMIT Licenseiosswiftui
movingparts.io/pow
4.3k195
DanielMartinus/Konfetti

Celebrate more with this lightweight confetti particle system 🎊

KotlinISC Licenseandroidkotlin
3.4k312
hunar4321/particle-life

A simple program to simulate artificial life using attraction/reuplsion forces between many particles

HTMLMIT Licensecppeducational
3.3k341
drawcall/Proton

Javascript particle animation library

JavaScriptnpmMIT Licenseparticlesparticle
drawcall.github.io/Proton/
2.5k283
whxaxes/canvas-test

🎮 happy canvas

HTMLMIT Licensecanvasjavascript
whxaxes.github.io/canvas-test/menu.html
2k984
raphamorim/awesome-canvas

A curated list of awesome HTML5 Canvas with examples, related articles and posts.

MarkdownMIT Licensehtml5-canvascanvas-element
1.8k172
vaneenige/phenomenon

⚡️ A fast 2kB low-level WebGL API.

TypeScriptnpmMIT Licensewebglparticles
1.8k47
layabox/LayaAir1.0

This is old LayaAir veriosn writetten by ActionScript 3.0 ,now LayaAir is using TypeScript as the Engine Script,Please use https://github.com/layabox/LayaAir instead.

JavaScriptnpmOtherwebglhtml5-engine
layabox.com
1.8k424