{"id":13476373,"url":"https://github.com/saadeghi/theme-change","last_synced_at":"2026-10-19T11:49:17.459Z","repository":{"id":40689506,"uuid":"258491101","full_name":"saadeghi/theme-change","owner":"saadeghi","description":"Change CSS theme with toggle, buttons or select using CSS custom properties and localStorage","archived":false,"fork":false,"pushed_at":"2026-06-14T01:19:42.000Z","size":128,"stargazers_count":1716,"open_issues_count":0,"forks_count":49,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-10-13T04:34:19.802Z","etag":null,"topics":["css-custom-properties","css-theme","css-variables","javascript","localstorage","theme","theming"],"latest_commit_sha":null,"homepage":"https://codepen.io/saadeghi/pen/OJypbNM","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/saadeghi.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":{"custom":"https://donate.lol/bitcoin:bc1qz9xhu04sf7r3chngc5ezts5yd60mc6hatugrly"}},"created_at":"2020-04-24T11:17:37.000Z","updated_at":"2026-09-28T07:16:03.000Z","dependencies_parsed_at":"2024-01-13T18:31:04.456Z","dependency_job_id":"f5b2fcb1-5d0d-4bb2-811a-70ab4ed9424f","html_url":"https://github.com/saadeghi/theme-change","commit_stats":{"total_commits":96,"total_committers":12,"mean_commits":8.0,"dds":0.15625,"last_synced_commit":"3ea64ec41c702c1787365b59a3c400cb890ec569"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/saadeghi/theme-change","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saadeghi%2Ftheme-change","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saadeghi%2Ftheme-change/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saadeghi%2Ftheme-change/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saadeghi%2Ftheme-change/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saadeghi","download_url":"https://codeload.github.com/saadeghi/theme-change/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saadeghi%2Ftheme-change/sbom","scorecard":{"id":794066,"data":{"date":"2025-08-11","repo":{"name":"github.com/saadeghi/theme-change","commit":"3ea64ec41c702c1787365b59a3c400cb890ec569"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":5,"reason":"Found 11/21 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/saadeghi/theme-change/npm-publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/saadeghi/theme-change/npm-publish.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/saadeghi/theme-change/npm-publish.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/npm-publish.yml:26","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 20 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T08:25:10.592Z","repository_id":40689506,"created_at":"2025-08-23T08:25:10.592Z","updated_at":"2025-08-23T08:25:10.592Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":344872684,"owners_count":38334586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-10-03T21:59:58.778Z","status":"online","status_checked_at":"2026-10-17T02:00:06.547Z","response_time":57,"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-custom-properties","css-theme","css-variables","javascript","localstorage","theme","theming"],"created_at":"2024-07-31T16:01:29.518Z","updated_at":"2026-10-19T11:49:17.452Z","avatar_url":"https://github.com/saadeghi.png","language":"JavaScript","funding_links":["https://donate.lol/bitcoin:bc1qz9xhu04sf7r3chngc5ezts5yd60mc6hatugrly"],"categories":["JavaScript","theme"],"sub_categories":[],"readme":"# 🎨 CSS Theme Change\n\nTiny helper for CSS themes.\n\n- One HTML attribute `data-set-theme` to set theme theme.\n- Works with button, select, and checkbox\n- Persists theme in localStorage\n- Syncs all matching `data-set-theme` controls\n\n[![][build]][build-url] [![][npm]][npm-url] [![][dl]][npm-url] \n\n## Demo\n\n- CodePen: https://codepen.io/saadeghi/pen/OJypbNM?editors=1000\n\n[![image](https://user-images.githubusercontent.com/7342023/80218042-e3c67e00-8655-11ea-94e8-925d0dcbfd57.gif)](#)\n\n## Quick start\n\n### CDN\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/theme-change@latest/index.js\"\u003e\u003c/script\u003e\n```\n\n### NPM\n\n```bash\nnpm i theme-change@latest\n```\n\n```js\nimport { themeChange } from \"theme-change\";\n\nthemeChange();\n```\n\nUse `themeChange(false)` when controls are mounted after initial page load.\n\n## Framework snippets\n\n\u003cdetails\u003e\n\u003csummary\u003eReact\u003c/summary\u003e\n\n```js\nimport { useEffect } from \"react\";\nimport { themeChange } from \"theme-change\";\n\nuseEffect(() =\u003e {\n  themeChange(false);\n}, []);\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVue\u003c/summary\u003e\n\n```js\nimport { onMounted } from \"vue\";\nimport { themeChange } from \"theme-change\";\n\nexport default {\n  setup() {\n    onMounted(() =\u003e {\n      themeChange(false);\n    });\n  },\n};\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eSvelte\u003c/summary\u003e\n\n```js\nimport { onMount } from \"svelte\";\nimport { themeChange } from \"theme-change\";\n\nonMount(() =\u003e {\n  themeChange(false);\n});\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eAstro\u003c/summary\u003e\n\n```astro\n---\nimport { themeChange } from \"theme-change\";\n---\n\n\u003cscript\u003e\n  themeChange(false);\n\u003c/script\u003e\n```\n\n\u003c/details\u003e\n\n## CSS setup\n\nUse [daisyUI](https://daisyui.com/) themes, or define your own theme tokens:\n\n```css\n:root {\n  --my-color: #fff;\n}\n[data-theme=\"dark\"] {\n  --my-color: #000;\n}\n[data-theme=\"pink\"] {\n  --my-color: #ffabc8;\n}\nbody {\n  background-color: var(--my-color);\n}\n```\n\n## HTML patterns\n\n| Pattern | Preview | Minimal code |\n| --- | --- | --- |\n| Button set | \u003cimg src=\"https://user-images.githubusercontent.com/7342023/101527827-c0adcc00-39a3-11eb-9e41-24bfa91ea96c.gif\" width=\"220\" alt=\"button theme\" /\u003e | `\u003cbutton data-set-theme=\"dark\"\u003eDark\u003c/button\u003e` |\n| Button rotate | \u003cimg src=\"https://user-images.githubusercontent.com/7342023/101527827-c0adcc00-39a3-11eb-9e41-24bfa91ea96c.gif\" width=\"220\" alt=\"button rotate\" /\u003e | `\u003cbutton data-set-theme=\"dark,light,pink\"\u003eRotate\u003c/button\u003e` |\n| Select | \u003cimg src=\"https://user-images.githubusercontent.com/7342023/101527790-b4297380-39a3-11eb-9173-bc909549d160.gif\" width=\"220\" alt=\"select theme\" /\u003e | `\u003cselect data-set-theme\u003e\u003coption value=\"\"\u003eDefault\u003c/option\u003e\u003coption value=\"dark\"\u003eDark\u003c/option\u003e\u003c/select\u003e` |\n| Checkbox | \u003cimg src=\"https://user-images.githubusercontent.com/7342023/101527821-bf7c9f00-39a3-11eb-822b-7751265a18a5.gif\" width=\"220\" alt=\"checkbox theme\" /\u003e | `\u003cinput type=\"checkbox\" value=\"dark\" data-set-theme /\u003e` |\n\nNotes:\n\n- For checkbox: checked sets theme, unchecked clears theme.\n- For rotate button: each click moves to the next item and loops.\n- Controls with the same `data-key` stay in sync.\n\n## Optional attributes\n\n### `data-act-class`\n\n```html\n\u003cbutton data-set-theme=\"\" data-act-class=\"ACTIVE\"\u003e\u003c/button\u003e\n\u003cbutton data-set-theme=\"dark\" data-act-class=\"ACTIVE\"\u003e\u003c/button\u003e\n\u003cbutton data-set-theme=\"pink\" data-act-class=\"ACTIVE\"\u003e\u003c/button\u003e\n```\n\n### `data-act-attribute`\n\nLike `data-act-class`, but sets an arbitrary HTML attribute (instead of a class) on a button while its theme is active, and removes it when inactive. Useful for accessibility state such as `aria-pressed` or `aria-current`.\n\n```html\n\u003c!-- name:value — active: aria-pressed=\"true\", inactive: attribute removed --\u003e\n\u003cbutton data-set-theme=\"dark\" data-act-attribute=\"aria-pressed:true\"\u003e\u003c/button\u003e\n\n\u003c!-- bare name (no colon) — boolean presence: active: aria-current=\"\", inactive: removed --\u003e\n\u003cbutton data-set-theme=\"pink\" data-act-attribute=\"aria-current\"\u003e\u003c/button\u003e\n```\n\nNotes:\n\n- Syntax is `name[:value]`. Only the **first** colon splits name and value, so the value may itself contain colons (e.g. `data-act-attribute=\"title:Active: dark\"`).\n- When inactive the attribute is fully removed (not set to a falsy value).\n- Button-only, same as `data-act-class` — ignored on `\u003cselect\u003e` and checkbox controls.\n- Can be combined with `data-act-class` on the same element.\n- Also works with the legacy `data-toggle-theme` buttons.\n\n### `data-key`\n\n```html\n\u003cselect data-set-theme data-key=\"admin-panel\"\u003e\u003c/select\u003e\n\u003cbutton data-set-theme=\"dark\" data-key=\"front-page\"\u003e\u003c/button\u003e\n\u003cinput type=\"checkbox\" value=\"pink\" data-set-theme data-key=\"premium-user-theme\" /\u003e\n```\n\n## Backward compatibility\n\nLegacy v2 attributes still work:\n\n- `data-toggle-theme`\n- `data-choose-theme`\n\n---\n\n[install-size]: https://badgen.net/bundlephobia/minzip/theme-change?label=bundle%20size\u0026color=purple\n[js]: https://badgen.net/badgesize/normal/https/unpkg.com/theme-change/index.js?label=file%20size\u0026color=purple\n[npm]: https://badgen.net/npm/v/theme-change?label=version\u0026color=purple\n[dl]: https://badgen.net/npm/dt/theme-change?icon=npm\u0026color=purple\n[commit]: https://badgen.net/github/last-commit/saadeghi/theme-change?icon=github\u0026color=purple\n[build]: https://badgen.net/github/checks/saadeghi/theme-change?label=build\n[build-url]: https://github.com/saadeghi/theme-change/actions\n[install-size-url]: https://bundlephobia.com/result?p=theme-change\n[js-url]: https://unpkg.com/theme-change@latest/index.js\n[npm-url]: https://www.npmjs.com/package/theme-change\n[gh-url]: https://github.com/saadeghi/theme-change\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaadeghi%2Ftheme-change","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaadeghi%2Ftheme-change","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaadeghi%2Ftheme-change/lists"}