How to update particlesjs colors in particlesConfig dynamically?

Viewed 42

Okay, so I am making a website and was able to setup shifting between darkmode and light mode using react styled-components and change the colors for body, and other elements using css

Only problem is I can't seem to find a way to update the colors in the particlesconfig.json

Any idea how I can do that?

1 Answers

A year late, but for future readers, particles.js exposes a window.pJSDom array. You can use it change the parameters and refresh the particles.

pJSDom[0].pJS.particles.color.value = '#ffffff';
pJSDom[0].pJS.particles.line_linked.color = '#ffffff';
pJSDom[0].pJS.fn.particlesRefresh();
Related