Skip to content

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.

License

Notifications You must be signed in to change notification settings

tsparticles/tsparticles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Repository files navigation

banner

tsParticles - TypeScript Particles

A lightweight TypeScript library for creating particles. Dependency free (*), browser ready and compatible with React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Riot.js, Solid.js, and Web Components

GitHub Sponsors jsDelivr hits (npm) Cdnjs npm npm lerna CodeFactor Codacy Badge Rate this package Gitpod Ready-to-Code Run on Repl.it

Discord Slack WhatsApp Telegram Reddit

tsParticles Product Hunt Buy Me A Coffee


Table of Contents


Do you want to use it on your website?

Documentation and Development referenceshere📖

This library is available on two of the most popular CDNs and it's easy and ready to use, if you were using particles.js it's even easier.

You'll find the instructionsbelow,with all the links you need, anddon't be scared byTypeScript,it's just the source language.

The output files are just JavaScript.🤩

CDNs andnpmhave all the sources you need inJavascript,a bundle browser ready (tsparticles.engine.min.js), and all files splitted forimportsyntax.

If you are interestedthere are somesimple instructions justbelowto guide you to migrate from the old particles.js library.

Library installation

Hosting / CDN

Please use these hosts or your own to load tsParticles on your projects

jsDelivr

jsDelivr jsDelivr jsDelivr jsDelivr jsDelivr jsDelivr jsDelivr

cdnjs

Cdnjs

unpkg

https://unpkg /@tsparticles/confetti/https://unpkg /@tsparticles/engine/https://unpkg /@tsparticles/fireworks/https://unpkg /@tsparticles/basic/https://unpkg /@tsparticles/slim/https://unpkg /tsparticles/https://unpkg /@tsparticles/all/


npm

tsParticles Confetti

npmnpmjs

tsParticles Engine

npmnpmjs

tsParticles Fireworks

npmnpmjs

tsParticles Basic

npmnpmjs

tsParticles Slim

npmnpmjs

tsParticles

npmnpmjs

tsParticles All

npmnpmjs

npm install @tsparticles/engine

yarn

yarn add @tsparticles/engine

pnpm

pnpm install @tsparticles/engine

Import and require

consttsParticles=require("@tsparticles/engine");

// or

import{tsParticles}from"@tsparticles/engine";

The importedtsParticlesis the same instance you have when including the script in the page using the<script>tag.


Usage

Load tsParticles and configure the particles:

tsParticles demo tsParticles Confetti demo

index.html

<divid= "tsparticles"></div>

<scriptsrc= "tsparticles.engine.min.js"></script>

app.js

// @path-json can be an object or an array, the first will be loaded directly, and the object from the array will be randomly selected
/* tsParticles.load(@params); */

tsParticles
.load({
id:"tsparticles",
url:"presets/default.json",
})
.then(container=>{
console.log("callback - tsparticles config loaded");
})
.catch(error=>{
console.error(error);
});

//or

tsParticles.load({
id:"tsparticles",
options:{
/* options here */
},
});

//or

tsParticles.load({
id:"tsparticles",
options:[
{
/* options here */
},
{
/* other options here */
},
],
});
//random object

tsParticles.load({
id:"tsparticles",
options:[
{
/* options here */
},
{
/* other options here */
},
],
index:1,
});//the second one
// Important! If the index is not in range 0...<array.length, the index will be ignored.

// after initialization this can be used.

/* tsParticles.setOnClickHandler(@callback); */

/* this will be fired from all particles loaded */

tsParticles.setOnClickHandler((event,particles)=>{
/* custom on click handler */
});

// now you can control the animations too, it's possible to pause and resume the animations
// these methods don't change the config so you're safe with all your configurations
// domItem(0) returns the first tsParticles instance loaded in the dom
constparticles=tsParticles.domItem(0);

// play will start the animations, if the move is not enabled it won't enable it, it just updates the frame
particles.play();

// pause will stop the animations
particles.pause();

Official components for some of the most used frameworks

Angular

@tsparticles/angular

npmnpm

Instructions availablehere

Astro

astro-particles

npmnpm

Instructions availablehere

Ember.js

ember-tsparticles

npmnpm

Instructions availablehere

Inferno

inferno-particles

npmnpm

Instructions availablehere

jQuery

jquery-particles

npmnpm

Instructions availablehere

Preact

preact-particles

npmnpm

Instructions availablehere

ReactJS

@tsparticles/react

npmnpm

Instructions availablehere

RiotJS

riot-particles

npmnpm

You can find the instructionshere

SolidJS

solid-particles

npmnpm

You can find the instructionshere

Svelte

@tsparticles/svelte

npmnpm downloads

Instructions availablehere

VueJS 2.x

@tsparticles/vue2

npmnpm

Instructions availablehere

VueJS 3.x

@tsparticles/vue3

npmnpm

Instruction availablehere

Web Components

web-particles

npmnpm

You can find the instructionshere

WordPress

@tsparticles/wordpress

npmnpmWordPress Plugin DownloadsWordPress Plugin Active Installs

The plugin page hosted on WordPress.org can be foundhere

Elementor

Actually, an official tsParticles plugin isn't existing, but I have a collaboration with thePremium Addons for Elementorplugin collection.

Premium Addons for Elementor
Premium Addons for Elementor is one of the most common plugins for Elementor that offers more than 55 highly customizable Elementor Widgets and Section Add-ons. tsParticles is exclusively included in Premium Particles Section Add-on for Elementor Page Builder.Check It Now.
Use Premium Addons for Elementor Page Builder and get the chance to include tsParticles in your next WordPress website without the need to write a single line of code.See a Live Example.

Presets

There are some presets ready to be used inthis repository,and they also have a bundle file that contains everything needed to run.

Big Circles

jsDelivrnpmjsnpmjs

This preset loads big colored circles moving upwards on a white background.

demo

You can find the instructionshere

Bubbles

jsDelivrnpmjsnpmjs

This preset loads colored bubbles coming from the bottom of the screen on a white background.

demo

You can find the instructionshere

Confetti

jsDelivrnpmjsnpmjs

This preset loads white and red confetti launched from the screen center on a transparent background.

demo

You can find the instructionshere

Fire

jsDelivrnpmjsnpmjs

This preset loads a faded red to a black background with particles colored like fire and ash sparks.

demo

You can find the instructionshere

Firefly

jsDelivrnpmjsnpmjs

This preset loads a mouse trail made with small fading particles like little fireflies.

demo

You can find the instructionshere

Fireworks

jsDelivrnpmjsnpmjs

This preset loads a beautiful fireworks effect.

demo

You can find the instructionshere

Fountain

jsDelivrnpmjsnpmjs

demo

You can find the instructionshere

Links

jsDelivrnpmjsnpmjs

demo

You can find the instructionshere

Sea Anemone

jsDelivrnpmjsnpmjs

demo

You can find the instructionshere

Snow

jsDelivrnpmjsnpmjs

demo

You can find the instructionshere

Stars

jsDelivrnpmjsnpmjs

demo

You can find the instructionshere

Triangles

jsDelivrnpmjsnpmjs

demo

You can find the instructionshere


Templates and Resources

You can find some tsParticles related templateshere.The templates are created forVanilla Javascript,ReactJS,VueJS,Angular,SvelteJS,and other frameworks.

The templates will vary, new ones can be created or older ones updated with the latest features or changed to a better style. Check them out once in a while.

If you created some good design withtsParticlesfeel free to submit a pull request with your cool template, you'll be credited as the template author!

https://github /tsparticles/templates


Demo / Generator

https://particles.js.org/samples

Particles demo


Video Tutorials

You can find all video tutorials on the website here:https://particles.js.org/video.html

More videos are coming soon! Check every day if there are some new contents.


Characters as particles

Particles chars demo


Polygon mask

tsParticles Polygon Mask demo


Animated stars

Particles NASA demo


Nyan cat flying on scrolling stars

Particles Nyan Cat demo


Snow particles

tsParticles Snow demo


Background Mask particles

tsParticles Background Mask demo


particles.json

You can find some config sampleshere📖


Options

You can find all options availablehere 📖

Want to see it in action and try it?

I've created a tsParticles collection onCodePen😮 or you can check out myprofile

Otherwise, there's the demo page link below.

tsParticles demo

Want to see even more demos? Clone the repository on your computer and follow these instructions

$ pnpm i
$ pnpm run build
$cddemo/vanilla
$ pnpm start

Boom! 💥http://localhost:3000and you can check out other demos.

If you are brave enoughyou can switch to thedevbranch for trying the features under development.


Migrating from Particles.js

tsParticleshas a package that makes this library 100% compatible with theparticles.jsconfiguration.

jsDelivrnpmjsnpm

Seriously, you just need to change the script from particles.js to the bundled compatibility package, et-voilà,you're ready🧙!

You can read morehere

Want to know 5 reasons to do the switch?Read here

Below you can find all the information you need to install tsParticles and its new syntax.


Plugins/Customizations

tsParticles now supports some customizations 🥳.

You can create your own plugins

Read morehere...


Dependency Graph

flowchart TD

subgraph core [Core]
engine[tsParticles Engine]
perlin-noise[Perlin Noise Lib]
simplex-noise[Simplex Noise Lib]
configs[tsParticles Configs]
end

subgraph bundle-basic [tsParticles Basic]

subgraph basic-movers [Movers]
move-base[Base]
end

subgraph basic-shapes [Shapes]
shape-circle[Circle]
end

subgraph basic-updates [Updaters]
updater-color[Color]
updater-opacity[Opacity]
updater-out-modes[Out Modes]
updater-size[Size]
end

end

engine --> bundle-basic

subgraph bundle-confetti [tsParticles Confetti]

subgraph confetti-plugins [Plugins]
plugin-emitters
plugin-motion
end

subgraph confetti-shapes [Shapes]
shape-cards
shape-emoji
shape-heart
shape-image
shape-polygon
shape-square
shape-star
end

subgraph confetti-updaters [Updaters]
updater-life
updater-roll
updater-rotate
updater-tilt
updater-wobble
end

end

bundle-basic --> bundle-confetti

subgraph bundle-slim [tsParticles Slim]

subgraph slim-interactions [Interactions]

subgraph slim-interactions-external [Externals]
interaction-external-attract[Attract]
interaction-external-bounce[Bounce]
interaction-external-bubble[Bubble]
interaction-external-connect[Connect]
interaction-external-grab[Grab]
interaction-external-pause[Pause]
interaction-external-push[Push]
interaction-external-remove[Remove]
interaction-external-repulse[Repulse]
interaction-external-slow[Slow]
end

subgraph slim-interactions-particles [Particles]
interaction-particles-attract[Attract]
interaction-particles-collisions[Collisions]
interaction-particles-links[Links]
end

end

subgraph slim-movers [Movers]
move-parallax[Parallax]
end

subgraph slim-plugins [Plugins]

subgraph slim-plugins-easings [Easings]
plugin-easing-quad[Quad]
end

end

subgraph slim-shapes [Shapes]
shape-emoji[Emoji]
shape-image[Image]
shape-line[Line]
shape-polygon[Polygon]
shape-square[Square]
shape-star[Star]
end

subgraph slim-updaters [Updaters]
updater-life[Life]
updater-rotate[Rotate]
updater-stroke-color[Stroke Color]
end

end

bundle-basic --> bundle-slim

subgraph bundle-fireworks [tsParticles Fireworks]

subgraph fireworks-effects [Effects]
effect-trail
end

subgraph fireworks-plugins [Plugins]
plugin-emitters

subgraph fireworks-plugin-emitters-shapes [Emitters Shapes]
plugin-emitters-shape-square
end

plugin-sounds
end

subgraph fireworks-updaters [Updaters]
updater-destroy
updater-life
updater-rotate
end

end

bundle-basic --> bundle-fireworks

subgraph bundle-full [tsParticles]

subgraph full-interactions [Interactions]

subgraph full-interactions-external [Externals]
interaction-external-trail[Trail]
end

end

subgraph full-plugins [Plugins]
plugin-absorbers[Absorbers]
plugin-emitters[Emitters]

subgraph full-plugin-emitters-shapes [Emitters Shapes]
plugin-emitters-shape-circle[Circle]
plugin-emitters-shape-square[Square]
end

end

subgraph full-shapes [Shapes]
shape-text[Text]
end

subgraph full-updaters [Updaters]
updater-destroy[Destroy]
updater-roll[Roll]
updater-tilt[Tilt]
updater-twinkle[Twinkle]
updater-wobble[Wobble]
end

end

bundle-slim --> bundle-full

subgraph bundle-all [tsParticles All]

bundle-pjs[tsParticles Particles.js Compatibility]

subgraph all-effects [Effects]
effect-bubble[Bubble]
effect-trail[Trail]
end

subgraph all-interactions [Interactions]
subgraph all-interactions-external [External]
interaction-external-particle[Particle]
interaction-external-pop[Pop]
end

interaction-light[Light]

subgraph all-interactions-particles [Particles]
interaction-particles-repulse[Repulse]
end
end

subgraph all-paths [Paths]
path-curl-noise[Curl Noise]
path-curves[Curves]
path-perlin-noise[Perlin Noise]
path-polygon[Polygon]
path-simplex-noise[Simplex Noise]
path-svg[SVG]
end

subgraph all-plugins [Plugins]
plugin-canvas-mask[Canvas Mask]

subgraph all-plugins-easings [Easings]
plugin-easing-back[Back]
plugin-easing-circ[Circ]
plugin-easing-cubic[Cubic]
plugin-easing-expo[Expo]
plugin-easing-linear[Linear]
plugin-easing-quart[Quart]
plugin-easing-quint[Quint]
plugin-easing-sine[Sine]
end

subgraph all-plugin-emitters-shapes [Emitters Shapes]
plugin-emitters-shape-canvas[Canvas]
plugin-emitters-shape-path[Path]
plugin-emitters-shape-polygon[Polygon]
end

subgraph all-plugins-exports [Exports]
plugin-export-image[Image]
plugin-export-json[JSON]
plugin-export-video[Video]
end

plugin-hsv-color[HSV Color]
plugin-infection[Infection]
plugin-motion[Motion]
plugin-poisson-disc[Poisson Disc]
plugin-polygon-mask[Polygon Mask]
plugin-sounds[Sounds]
end

subgraph all-shapes [Shapes]
shape-arrow[Arrow]
shape-cards[Cards]
shape-cog[Cog]
shape-heart[Heart]
shape-path[Path]
shape-rounded-polygon[Rounded Polygon]
shape-rounded-rect[Rounded Rect]
shape-spiral[Spiral]
end

subgraph all-updaters [Updaters]
updater-gradient[Gradient]
updater-orbit[Orbit]
end

simplex-noise --> path-curl-noise
perlin-noise --> path-perlin-noise
simplex-noise --> path-simplex-noise

end

bundle-full --> bundle-all
Loading

JetBrains JetBrains

Sponsors

JetBrains

Huge thanks toJetBrainsfor the 2020-2022 Open Source Licenses!

JetBrains WebStormis used to maintain this project.