tsParticles
tsParticles - Easily create highly customizable JavaScript particles effect...
README
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
[](https://www.producthunt.com/posts/tsparticles?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-tsparticles") [](https://www.buymeacoffee.com/matteobruni) Table of Contents
⚠️⚠️ \_This readme refers to v2
version, read here forv1 documentation\* ⚠️⚠️
- Angular
- Inferno
- jQuery
- Preact
- ReactJS
- RiotJS
- SolidJS
- Svelte
- Presets
- Bubbles
- Confetti
- Fire
- Firefly
- Fountain
- Links
- Snow
- Stars
- Sponsors
Do you want to use it on your website?
_Documentation and Development references here 📖_
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
instructions below, with all the
links you need, and _don't be scared by TypeScript, it's just the source language_.
The output files are just JavaScript. 🤩
CDNs and npm have all the sources you need in Javascript, a bundle browser ready (tsparticles.engine.min.js), and
all
files splitted for import syntax.
If you are interested there are some _simple instructions_
just below to 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
cdnjs
unpkg
_npm_
_tsParticles Engine_
_tsParticles Slim_
_tsParticles_
- ``` sh
- npm install tsparticles-engine
- ```
_yarn_
- ``` sh
- yarn add tsparticles-engine
- ```
_pnpm_
- ``` sh
- pnpm install tsparticles-engine
- ```
Import and require
Starting from version 1.12.11 import and require can be used to import tsParticles .
Now you can write something like this
- ``` js
- const tsParticles = require("tsparticles-engine");
- // or
- import { tsParticles } from "tsparticles-engine";
- ```
The imported tsParticles is the same instance you have when including the script.
_NuGet_
_Usage_
Load tsParticles and configure the particles:
index.html
- ``` html
- <div id="tsparticles"></div>
- <script src="tsparticles.engine.min.js"></script>
- ```
app.js
- ``` 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.loadJSON(@dom-id, @path-json, @callback (optional)); */
- tsParticles
- .loadJSON("tsparticles", "presets/default.json")
- .then(container => {
- console.log("callback - tsparticles config loaded");
- })
- .catch(error => {
- console.error(error);
- });
- //or
- /* tsParticles.load(@dom-id, @options); */
- tsParticles.load("tsparticles", {
- /* options here */
- });
- //or
- /* tsParticles.loadFromArray(@dom-id, @options, @index (optional)); */
- tsParticles.loadFromArray("tsparticles", [
- {
- /* options here */
- },
- {
- /* other options here */
- },
- ]);
- //random object
- tsParticles.loadFromArray(
- "tsparticles",
- [
- {
- /* options here */
- },
- {
- /* other options here */
- },
- ],
- 1
- ); //the second one
- // Important! If the index is not in range 0...
- // 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
- const particles = 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
ng-particles
Instructions available here
Inferno
inferno-particles
Instructions available here
jQuery
jquery-particles
Instructions available here
Preact
preact-particles
Instructions available here
ReactJS
react-particles
Instructions available here
RiotJS
riot-particles
You can find the instructions here
SolidJS
solid-particles
You can find the instructions here
Svelte
svelte-particles
Instructions available here
VueJS 2.x
vue2-particles
Instructions available here
VueJS 3.x
vue3-particles
Instruction available here
Web Components
web-particles
You can find the instructions here
WordPress
wordpress-particles
The plugin page hosted on WordPress.org can be
found here
Elementor
Actually, an official tsParticles plugin isn't existing, but I have a collaboration with
the Premium Addons for Elementor plugin collection.

Premium Addons for Elementor is one of the most common plugins for Elementor that offers 55+ highly customizable Elementor Widgets and Section Add-ons. tsParticles is exclusively included in the Premium Particles Section Add-on for the 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 writing a single line of code. See a Live Example.
Use Premium Addons for Elementor Page Builder and get the chance to include tsParticles in your next WordPress website without writing a single line of code. See a Live Example.
Presets
There are some presets ready to be used in this repository, and they also have a bundle file that contains everything
needed to run.
Big Circles
This preset loads big colored circles moving upwards on a white background.
You can find the instructions here
Bubbles
This preset loads colored bubbles coming from the bottom of the screen on a white background.
You can find the instructions here
Confetti
This preset loads white and red confetti launched from the screen center on a transparent background.
You can find the instructions here
Fire
This preset loads a faded red to a black background with particles colored like fire and ash sparks.
You can find the instructions here
Firefly
This preset loads a mouse trail made with small fading particles like little fireflies.
You can find the instructions here
Fireworks
This preset loads a beautiful fireworks effect.
You can find the instructions here
Fountain
You can find the instructions here
Links
You can find the instructions here
Sea Anemone
You can find the instructions here
Snow
You can find the instructions here
Stars
You can find the instructions here
Triangles
You can find the instructions here
Templates and Resources
You can find some tsParticles related templates here. The templates are
created for _Vanilla 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 with _tsParticles_ feel free to submit a pull request with your cool template, you'll be
credited as the template author!
_Demo / Generator_
_Video Tutorials_
_More videos are coming soon! Check every day if there are some new contents._
Characters as particles
Polygon mask
Animated stars
Nyan cat flying on scrolling stars
Snow particles
Background Mask particles
particles.json
You can find some config samples here 📖
_Options_
You can find all options
available here 📖
Want to see it in action and try it?
I've created a tsParticles collection on CodePen 😮 or you can check out
my profile
Otherwise, there's the demo page link below. Just click/tap the Coronavirus below, don't be scared. It's safe 😷.
Want to see even more demos? Clone the repository on your computer and follow these instructions
- ``` sh
- $ pnpm i
- $ npx lerna run build
- $ cd demo/vanilla
- $ pnpm run start
- ```
_If you are brave enough_ you can switch to the dev branch for trying the features under development.
Migrating from Particles.js
tsParticles has a package that makes this library 100% compatible with the _particles.js_ configuration.
Seriously, you just need to change the script from particles.js to the bundled compatibility package, et-voilà, you're
ready 🧙!
You can read more here
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 more here..._
Dependency Graphs
- ```mermaid
- flowchart TD
- subgraph c [Components]
- ca[Angular]
- ci[Inferno.js]
- cj[JQuery]
- cp[Preact]
- cre[React.js]
- cri[Riot.js]
- cso[Solid.js]
- csv[Svelte]
- cv2[Vue.js 2.x]
- cv3[Vue.js 3.x]
- cw[Web Components]
- end
- e[tsParticles Engine] --> c
- ```
- ```mermaid
- flowchart LR
- subgraph b [Bundles]
- bp[Particles.js compatibility bundle] --> bs[tsParticles Slim]
- bs --> bf[tsParticles]
- end
- e[tsParticles Engine] --> b
- iea & iebo & iebu & iec & ieg & iepa & iepu & ierem & ierep --> bs
- ipa & ipc & ipl --> bs
- mb & mp --> bs
- sc & si & sl & sp & ssq & sst & st --> bs
- ua & uc & ul & uop & uou & usi & ust --> bs
- iet --> bf
- pla & ple & plp --> bf
- ur & uti & utw & uw --> bf
- subgraph i [Interactions]
- subgraph ie [Externals]
- iea[Attract]
- iebo[Bounce]
- iebu[Bubble]
- iec[Connect]
- ieg[Grab]
- iepa[Pause]
- iepu[Push]
- ierem[Remove]
- ierep[Repulse]
- iet[Trail]
- end
- il[Light]
- subgraph ip [Particles]
- ipa[Attract]
- ipc[Collisions]
- ipl[Links]
- ipr[Repulse]
- end
- end
- i --> ie
- i --> ip
- e --> i
- subgraph m [Movers]
- mb[Base]
- mp[Parallax]
- end
- e --> m
- subgraph pa [Paths]
- pac[Curves]
- pape[Perlin Noise]
- papo[Polygon]
- pas[Simplex Noise]
- end
- e --> pa
- subgraph pl [Plugins]
- pla[Absorbers]
- ple[Emitters]
- pli[Infection]
- plp[Polygon Mask]
- end
- e --> pl
- subgraph s [Shapes]
- sb[Bubble]
- sc[Circle]
- sh[Heart]
- si[Image]
- sl[Line]
- sm[Multiline Text]
- sp[Polygon]
- sr[Rounded Rectangle]
- ssp[Spiral]
- ssq[Square]
- sst[Star]
- st[Text]
- end
- e --> s
- subgraph u [Updaters]
- ua[Angle]
- uc[Color]
- ug[Gradient]
- ul[Life]
- uop[Opacity]
- uor[Orbit]
- uou[Out Modes]
- ur[Roll]
- usi[Size]
- ust[Stroke Color]
- uti[Tilt]
- utw[Twinkle]
- uw[Wobble]
- end
- e --> u
- subgraph pr [Presets]
- prbi[Big Circles]
- prbu[Bubbles]
- prc[Confetti]
- prf[Fire]
- prff[Firefly]
- prfw[Fireworks]
- prfo[Fountain]
- prl[Links]
- prsa[Sea Anemone]
- prsn[Snow]
- prst[Stars]
- prt[Triangles]
- end
- e --> pr
- ```
Huge thanks to JetBrains for the 2020-2022 Open Source Licenses!
JetBrains WebStorm is used to maintain this project.
Sponsors
Codacy is a code quality platform that helps you to detect and fix code quality issues in your
code.
Automate code reviews on your commits and pull requests
Check your code quality and keep track of your technical debt for more than 40 programming languages. Seamlessly
integrated within your development workflow.