tsParticles - v4.0.0-beta.12
    Preparing search index...

    Plugins and Customizations

    tsParticles can be extended with plugins, custom shapes, and custom presets.

    This page provides a practical flow to build extensions that users can reuse easily.

    • Custom shape: when you need a new particle drawing primitive
    • Custom preset: when you want to reuse the same effect across many projects
    • Plugin: when you need new runtime behavior, interactions, or rendering logic
    • Register shape/preset before calling tsParticles.load(...)
    • Use a unique name (for example, with a project prefix)
    • Always document a minimal configuration example
    • If you are starting from an existing demo object, keep that config as a fixture while developing your extension

    Register a shape with tsParticles.addShape(name, drawer).

    tsParticles.addShape("spiral", (context, particle, radius) => {
    const data = particle.shapeData as { innerRadius: number; lineSpacing: number };
    const realWidth = (radius - data.innerRadius) / data.lineSpacing;

    for (let i = 0; i < realWidth * 10; i++) {
    const angle = 0.1 * i;
    const factor = data.innerRadius + data.lineSpacing * angle;

    context.lineTo(factor * Math.cos(angle), factor * Math.sin(angle));
    }
    });
    class SpiralDrawer {
    draw(context, particle, radius) {
    const data = particle.shapeData;
    const realWidth = (radius - data.innerRadius) / data.lineSpacing;

    for (let i = 0; i < realWidth * 10; i++) {
    const angle = 0.1 * i;
    const factor = data.innerRadius + data.lineSpacing * angle;

    context.lineTo(factor * Math.cos(angle), factor * Math.sin(angle));
    }
    }
    }

    tsParticles.addShape("spiral", new SpiralDrawer());

    Useful interface: IShapeDrawer

    {
    "particles": {
    "shape": {
    "type": "spiral",
    "options": {
    "spiral": {
    "innerRadius": 1,
    "lineSpacing": 1,
    "close": false,
    "fill": false
    }
    }
    }
    }
    }

    Register a preset with tsParticles.addPreset(name, options) and then use it in config with preset.

    tsParticles.addPreset("my-fire", {
    fpsLimit: 40,
    particles: {
    number: {
    value: 80,
    },
    move: {
    enable: true,
    speed: 6,
    },
    color: {
    value: ["#fdcf58", "#757676", "#f27d0c", "#800909", "#f07f13"],
    },
    },
    background: {
    image: "radial-gradient(#4a0000, #000)",
    },
    });

    Preset usage:

    {
    "preset": "my-fire"
    }
    • For shapes: use the tsparticles-shape tag
    • For presets: use the tsparticles-preset tag
    • Include in README: installation, registration snippet, config snippet
    • Start from @tsparticles/configs if you need a concrete object to evolve into a preset
    • Start from the official presets repository if you need a ready effect close to your target result
    • Use palettes when behavior is already correct and only the color identity should change