{"id":20529743,"url":"https://github.com/7ph/react-powerglitch","last_synced_at":"2025-08-18T01:37:55.304Z","repository":{"id":133286808,"uuid":"537949823","full_name":"7PH/react-powerglitch","owner":"7PH","description":"Tiny React library to glitch anything on the web","archived":false,"fork":false,"pushed_at":"2025-01-16T15:24:08.000Z","size":1837,"stargazers_count":147,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-10T23:46:29.393Z","etag":null,"topics":["css","css-animations","gifs","glitch-art","glitch-effect","glitched-images","glitchify-images","glitching","javascript","library","mosh","react","reactjs"],"latest_commit_sha":null,"homepage":"https://7ph.github.io/powerglitch/#/","language":"TypeScript","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/7PH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2022-09-17T23:02:15.000Z","updated_at":"2025-07-31T23:55:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"c7cbcecf-af93-47fc-abd3-c618b6ec1caa","html_url":"https://github.com/7PH/react-powerglitch","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/7PH/react-powerglitch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7PH%2Freact-powerglitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7PH%2Freact-powerglitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7PH%2Freact-powerglitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7PH%2Freact-powerglitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/7PH","download_url":"https://codeload.github.com/7PH/react-powerglitch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7PH%2Freact-powerglitch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270932581,"owners_count":24670241,"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","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["css","css-animations","gifs","glitch-art","glitch-effect","glitched-images","glitchify-images","glitching","javascript","library","mosh","react","reactjs"],"created_at":"2024-11-15T23:33:57.313Z","updated_at":"2025-08-18T01:37:55.279Z","avatar_url":"https://github.com/7PH.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React PowerGlitch\n\n\u003cimg src=\"./assets/intro.gif\" alt=\"\"\u003e\n\nThis React library is a wrapper around [PowerGlitch](https://github.com/7PH/powerglitch). PowerGlitch is a standalone library with no external dependencies. It leverages CSS animations to glitch anything on the web, without using a canvas. It weights less than 2kb minified and gzipped.\n\n- [Original project repository and documentation](https://github.com/7PH/powerglitch)\n- [Code coverage report for react-powerglitch](https://7ph.github.io/react-powerglitch/coverage/lcov-report/)\n- [API reference for react-powerglitch](https://7ph.github.io/react-powerglitch/api-docs/)\n\n# Getting started\n\n\u003cp align=\"center\"\u003e\n \u003ca href=\"#install\"\u003eInstall\u003c/a\u003e\n → \u003ca href=\"#glitch\"\u003eGlitch\u003c/a\u003e\n → \u003ca href=\"#customize\"\u003eCustomize\u003c/a\u003e\n → \u003ca href=\"#glitch-controls\"\u003eControls\u003c/a\u003e\n / \u003ca href=\"#typescript\"\u003eTypeScript\u003c/a\u003e\n\u003c/p\u003e\n\n## Install\n\n1. Install `react-powerglitch` using a package manager\n    ```bash\n    npm i --save react-powerglitch\n    # or\n    yarn add react-powerglitch\n    ```\n\n2. Import the `useGlitch` hook from `react-powerglitch` anytime you want to use it.\n    ```js\n    import { useGlitch } from 'react-powerglitch'\n    ```\n\n## Glitch\n\nIn order to glitch something, call `useGlitch()` and store its result in a variable.\n```jsx\nfunction App() {\n    const glitch = useGlitch();\n\n    return (\n        \u003ch1\u003ereact-powerglitch \u003cspan ref={glitch.ref}\u003e🌎\u003c/span\u003e\u003c/h1\u003e\n    );\n}\n```\n\nOne limitation, when having the `createContainers` option set to true (which is the default), to not place the glitched element as the direct child of a component or a conditional rendering block. E.g. this will **not** work:\n```jsx\n\u003c\u003e\n    {/* Will not work */}\n    {condition \u0026\u0026\n        \u003cspan ref={glitch.ref}\u003e🌎\u003c/span\u003e\n    }\n\u003c/\u003e\n```\n\nInstead, wrap the glitched element with a container:\n```jsx\n\u003c\u003e\n    {/* Will work */}\n    {condition \u0026\u0026\n        \u003cdiv\u003e\n            \u003cspan ref={glitch.ref}\u003e🌎\u003c/span\u003e\n        \u003c/div\u003e\n    }\n\u003c/\u003e\n```\n\n## Customize\n\nYou can pass options to customize the glitch effect to `useGlitch`:\n```jsx\nfunction App() {\n    const glitch = useGlitch({ glitchTimeSpan: false });\n\n    return (\n        \u003ch1\u003ereact-powerglitch \u003cspan ref={glitch.ref}\u003e🌎\u003c/span\u003e\u003c/h1\u003e\n    );\n}\n```\n\nThe `options` props accept any value defined in [the original PowerGlitch library](https://github.com/7PH/powerglitch).\n\nTake a look at the [playground](https://7ph.github.io/powerglitch/#/playground) to visually find out the best glitch options for your element.\n\n## Glitch controls \n\nThe `useGlitch` hook returns an object containing:\n- `ref`: A function ref which you should use on the element you want to glitch, as shown in previous sections.\n- `startGlitch`: Glitch control functions to start the glitch animation.\n- `stopGlitch`: Glitch control functions to stop the glitch animation.\n- `setOptions`: A function to change the glitch options. This will update the glitched element with the new options.\n\nHere is an example:\n```jsx\nfunction App() {\n    const glitch = useGlitch({ glitchTimeSpan: false });\n\n    return (\n        \u003c\u003e\n            \u003cdiv\u003e\n                \u003ch1 ref={glitch.ref}\u003ereact-powerglitch 🌎\u003c/h1\u003e\n            \u003c/div\u003e\n            \u003cbutton onClick={glitch.startGlitch}\u003e\n                Start\n            \u003c/button\u003e\n            \u003cbutton onClick={glitch.stopGlitch}\u003e\n                Stop\n            \u003c/button\u003e\n        \u003c/\u003e\n    );\n}\n```\n\n## TypeScript\n\nThe type `GlitchHandle` represents the return type of the `useGlitch` hook.\n\nYour IDE should automatically identify the return type of `useGlitch` to be `GlitchHandle` and assign it to any variable you assign `useGlitch()` to. In case you want to statically use it, import `GlitchHandle` from `react-powerglitch`.\n\n```tsx\nimport { useGlitch, GlitchHandle } from 'react-powerglitch';\n\nfunction App() {\n    const glitch: GlitchHandle = useGlitch({ glitchTimeSpan: false });\n\n    return (\n        \u003c\u003e\n            \u003cdiv\u003e\n                \u003ch1 ref={glitch.ref}\u003ereact-powerglitch 🌎\u003c/h1\u003e\n            \u003c/div\u003e\n            \u003cbutton onClick={glitch.startGlitch}\u003e\n                Start\n            \u003c/button\u003e\n            \u003cbutton onClick={glitch.stopGlitch}\u003e\n                Stop\n            \u003c/button\u003e\n        \u003c/\u003e\n    );\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7ph%2Freact-powerglitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F7ph%2Freact-powerglitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7ph%2Freact-powerglitch/lists"}