{"id":15284289,"url":"https://github.com/tsparticles/preact","last_synced_at":"2025-04-12T23:21:38.401Z","repository":{"id":103337690,"uuid":"564549709","full_name":"tsparticles/preact","owner":"tsparticles","description":"Preact.js tsParticles official component","archived":false,"fork":false,"pushed_at":"2025-04-08T11:10:47.000Z","size":489,"stargazers_count":8,"open_issues_count":11,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-08T12:24:25.765Z","etag":null,"topics":["hacktoberfest","javascript","preact","tsparticles","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsparticles.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"matteobruni,tsparticles"}},"created_at":"2022-11-11T00:30:12.000Z","updated_at":"2025-01-29T01:56:37.000Z","dependencies_parsed_at":"2023-12-15T20:08:14.161Z","dependency_job_id":"2ebe8e59-b8f5-4759-a1a2-1f156241ea3f","html_url":"https://github.com/tsparticles/preact","commit_stats":{"total_commits":30,"total_committers":2,"mean_commits":15.0,"dds":0.2666666666666667,"last_synced_commit":"32b99a473b746a050f98724ddd1ffbe2faaf4ccb"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsparticles%2Fpreact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsparticles%2Fpreact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsparticles%2Fpreact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsparticles%2Fpreact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsparticles","download_url":"https://codeload.github.com/tsparticles/preact/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247840962,"owners_count":21005017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","javascript","preact","tsparticles","typescript"],"created_at":"2024-09-30T14:52:54.444Z","updated_at":"2025-04-12T23:21:38.362Z","avatar_url":"https://github.com/tsparticles.png","language":"JavaScript","funding_links":["https://github.com/sponsors/matteobruni,tsparticles","https://github.com/sponsors/matteobruni","https://www.buymeacoffee.com/matteobruni","https://img.buymeacoffee.com/button-api/?text=Buy"],"categories":[],"sub_categories":[],"readme":"[![banner](https://particles.js.org/images/banner3.png)](https://particles.js.org)\n\n# @tsparticles/preact\n\n[![npm](https://img.shields.io/npm/v/@tsparticles/preact)](https://www.npmjs.com/package/@tsparticles/preact) [![npm](https://img.shields.io/npm/dm/@tsparticles/preact)](https://www.npmjs.com/package/@tsparticles/preact) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)\n\nOfficial [tsParticles](https://github.com/matteobruni/tsparticles) Preact component\n\n[![Slack](https://particles.js.org/images/slack.png)](https://join.slack.com/t/tsparticles/shared_invite/enQtOTcxNTQxNjQ4NzkxLWE2MTZhZWExMWRmOWI5MTMxNjczOGE1Yjk0MjViYjdkYTUzODM3OTc5MGQ5MjFlODc4MzE0N2Q1OWQxZDc1YzI) [![Discord](https://particles.js.org/images/discord.png)](https://discord.gg/hACwv45Hme) [![Telegram](https://particles.js.org/images/telegram.png)](https://t.me/tsparticles)\n\n[![tsParticles Product Hunt](https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=186113\u0026theme=light)](https://www.producthunt.com/posts/tsparticles?utm_source=badge-featured\u0026utm_medium=badge\u0026utm_souce=badge-tsparticles\") \u003ca href=\"https://www.buymeacoffee.com/matteobruni\"\u003e\u003cimg src=\"https://img.buymeacoffee.com/button-api/?text=Buy me a beer\u0026emoji=🍺\u0026slug=matteobruni\u0026button_colour=5F7FFF\u0026font_colour=ffffff\u0026font_family=Arial\u0026outline_colour=000000\u0026coffee_colour=FFDD00\"\u003e\u003c/a\u003e\n\n## Installation\n\n```shell\nnpm install @tsparticles/preact\n```\n\nor\n\n```shell\nyarn add @tsparticles/preact\n```\n\n## How to use\n\n### Code\n\nExamples:\n\n_Remote url_\n\n```javascript\nimport Particles, { initParticlesEngine } from \"@tsparticles/preact\";\nimport { loadFull } from \"tsparticles\";\n\nclass App extends Component {\n    state = {\n        particlesInitialized: false,\n    };\n\n    constructor(props) {\n        super(props);\n\n        this.particlesLoaded = this.particlesLoaded.bind(this);\n\n        initParticlesEngine(async engine =\u003e {\n            // you can initialize the tsParticles instance (main) here, adding custom shapes or presets\n            // this loads the tsparticles package bundle, it's the easiest method for getting everything ready\n            // starting from v2 you can add only the features you need reducing the bundle size\n            await loadFull(engine);\n        }).then(() =\u003e {\n            this.setState({\n                particlesInitialized: true,\n            });\n        });\n    }\n\n    particlesLoaded(container) {\n        console.log(container);\n    }\n\n    render() {\n        if (!this.state.particlesInitialized) {\n            return null;\n        }\n\n        return (\n            \u003cParticles id=\"tsparticles\" url=\"http://foo.bar/particles.json\" particlesLoaded={this.particlesLoaded} /\u003e\n        );\n    }\n}\n```\n\n_Options object_\n\n```javascript\nimport Particles from \"@tsparticles/preact\";\nimport { loadFull } from \"tsparticles\";\n\nclass App extends Component {\n    state = {\n        particlesInitialized: false,\n    };\n\n    constructor(props) {\n        super(props);\n\n        this.particlesLoaded = this.particlesLoaded.bind(this);\n\n        initParticlesEngine(async engine =\u003e {\n            // you can initialize the tsParticles instance (main) here, adding custom shapes or presets\n            // this loads the tsparticles package bundle, it's the easiest method for getting everything ready\n            // starting from v2 you can add only the features you need reducing the bundle size\n            await loadFull(engine);\n        }).then(() =\u003e {\n            this.setState({\n                particlesInitialized: true,\n            });\n        });\n    }\n\n    particlesLoaded(container) {\n        console.log(container);\n    }\n\n    render() {\n        if (!this.state.particlesInitialized) {\n            return null;\n        }\n\n        return (\n            \u003cParticles\n                id=\"tsparticles\"\n                particlesLoaded={this.particlesLoaded}\n                options={{\n                    background: {\n                        color: {\n                            value: \"#0d47a1\",\n                        },\n                    },\n                    fpsLimit: 120,\n                    interactivity: {\n                        events: {\n                            onClick: {\n                                enable: true,\n                                mode: \"push\",\n                            },\n                            onHover: {\n                                enable: true,\n                                mode: \"repulse\",\n                            },\n                            resize: true,\n                        },\n                        modes: {\n                            push: {\n                                quantity: 4,\n                            },\n                            repulse: {\n                                distance: 200,\n                                duration: 0.4,\n                            },\n                        },\n                    },\n                    particles: {\n                        color: {\n                            value: \"#ffffff\",\n                        },\n                        links: {\n                            color: \"#ffffff\",\n                            distance: 150,\n                            enable: true,\n                            opacity: 0.5,\n                            width: 1,\n                        },\n                        move: {\n                            direction: \"none\",\n                            enable: true,\n                            outModes: {\n                                default: \"bounce\",\n                            },\n                            random: false,\n                            speed: 6,\n                            straight: false,\n                        },\n                        number: {\n                            density: {\n                                enable: true,\n                                area: 800,\n                            },\n                            value: 80,\n                        },\n                        opacity: {\n                            value: 0.5,\n                        },\n                        shape: {\n                            type: \"circle\",\n                        },\n                        size: {\n                            value: { min: 1, max: 5 },\n                        },\n                    },\n                    detectRetina: true,\n                }}\n            /\u003e\n        );\n    }\n}\n```\n\n### Props\n\n| Prop            | Type     | Definition                                                                                                                                  |\n| --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |\n| id              | string   | The id of the element.                                                                                                                      |\n| width           | string   | The width of the canvas.                                                                                                                    |\n| height          | string   | The height of the canvas.                                                                                                                   |\n| options         | object   | The options of the particles instance.                                                                                                      |\n| url             | string   | The remote options url, called using an AJAX request                                                                                        |\n| style           | object   | The style of the canvas element.                                                                                                            |\n| className       | string   | The class name of the canvas wrapper.                                                                                                       |\n| canvasClassName | string   | the class name of the canvas.                                                                                                               |\n| container       | object   | The instance of the [particles container](https://particles.js.org/docs/modules/Core_Container.html)                                        |\n| particlesLoaded | function | This function is called when particles are correctly loaded in canvas, the current container is the parameter and you can customize it here |\n\nFind your parameters configuration [here](https://particles.js.org).\n\n## Demos\n\nThe demo website is [here](https://particles.js.org)\n\n\u003chttps://particles.js.org\u003e\n\nThere's also a CodePen collection actively maintained and updated [here](https://codepen.io/collection/DPOage)\n\n\u003chttps://codepen.io/collection/DPOage\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsparticles%2Fpreact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsparticles%2Fpreact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsparticles%2Fpreact/lists"}