tsParticles - Easily add highly customizable particles animations to your website
tsParticles is a lightweight library that lets you create beautiful particle animations that you can customize deeply.
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.
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
Table of Contents
-
tsParticles - TypeScript Particles
- Table of Contents
- Do you want to use it on your website?
- Library installation
- Official components for some of the most used frameworks
- Presets
- Templates and Resources
- Demo / Generator
- Video Tutorials
- …
If you are using React
, Vue.js
(2.x or 3.x), Angular
, Svelte
, jQuery
, Inferno
or Preact
you can find a ready to use official component instead of creating your own.
You'll find all the instructions needed below, and if you have questions you can reach me on GitHub or join the official tsParticles Slack here
Samples
Particles background for login form
Particles mouse trail unveiling background
Smoke Particles Effect
Starry night
Snow
Usage
Vanilla Javascript
CDNs
You can easily add tsParticles with the most used CDNs
cdnjs
Checkout the cdnjs page to get the latest version here
jsDelivr
Checkout the jsDelivr page to get the latest version here
unpkg
Unpkg doesn't have a simple UI like jsDelivr or cdnjs but you can simply use the following link in a script tag to have always the latest version
https://unpkg.com/tsparticles
If you want to see all versions available go here
index.html
<!-- particles container -->
<div id="tsparticles"></div>
<!-- script -->
<!-- jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/tsparticles"></script>
<script src="app.js"></script>
app.js
tsParticles.load("tsparticles", /* paste options here */);
NPM / Yarn
yarn add tsparticles
or
npm install tsparticles
ES Module
app.js
import { tsParticles } from "tsparticles";
tsParticles.load("tsparticles", /* paste options here */);
Warning: This file must be built for client side usage, SSR is not supported.
CommonJS (NodeJS)
app.js
const tsp = require("tsparticles");
tsp.tsParticles.load("tsparticles", /* paste options here */);
ReactJS
yarn add react-tsparticles
or
npm install react-tsparticles
import Particles from "react-tsparticles";
// component syntax, use it in your markup
<Particles options={/* paste options here */} />
PreactJS
yarn add preact-particles
or
npm install preact-particles
import Particles from "preact-particles";
// component syntax, use it in your markup
<Particles options={/* paste options here */} />
Inferno
yarn add inferno-particles
or
npm install inferno-particles
import Particles from "inferno-particles";
// component syntax, use it in your markup
<Particles options={/* paste options here */} />
Angular
yarn add ng-particles
or
npm install ng-particles
template.html
<Particles id="tsparticles" [options]="particlesOptions"></Particles>
app.ts
export class AppComponent {
/* particlesOptions is the value used in the template */
particlesOptions = /* paste options here */;
}
app.module.ts
import { NgParticlesModule } from 'ng-particles';
import { NgModule } from "@angular/core";
@NgModule({
declarations: [ /* AppComponent */ ],
imports: [
/* other imports */
NgParticlesModule // NgParticlesModule is required
],
providers: [],
bootstrap: [ /* AppComponent */ ]
})
export class AppModule { }
VueJS
2.x
yarn add particles.vue
or
npm install particles.vue
app.js
import Particles from 'particles.vue';
Vue.use(Particles);
template.vue
<template>
<div id="app">
<Particles id="tsparticles" :options="{ /* your options here */ }"></Particles>
</div>
</template>
3.x
yarn add particles.vue3
or
npm install particles.vue3
app.js
import Particles from 'particles.vue3';
createApp(App).use(Particles)
template.vue
<template>
<div id="app">
<Particles id="tsparticles" :options="{ /* your options here */ }"></Particles>
</div>
</template>
Svelte
npm install svelte-particles
or
yarn add svelte-particles
Usage
<script>
import Particles from "svelte-particles";
let particlesConfig = {
/* your options here */
};
</script>
<Particles id="tsparticles" options="{particlesConfig}" />
Configurations
You can checkout all tsParticles options from here
You can customize some presets here
There's also an official CodePen collection here
https://codepen.io/collection/DPOage
Migrating from particles.js
tsParticles fully supports all existing particles.js configurations.
You can check out this guide to easily migrate to tsParticles
Thanks
Thanks for reading, and if you liked the project support it with a star on GitHub
Top comments (4)
Wow, going to try this out. I'm a very bad coder overall but amazing for my age, so implementing this probably won't be too hard.
DevKidsAreAwesome
Thanks, and if you need help feel free to open an issue on GitHub
This is a really cool Project. Found this a few months back on Github and immediately starred ⭐️ . Keep going :)
Thank you so much 🤩