{"id":15679091,"url":"https://github.com/shahednasser/use-dark-mode-hook","last_synced_at":"2026-03-02T07:32:48.995Z","repository":{"id":38399058,"uuid":"344595773","full_name":"shahednasser/use-dark-mode-hook","owner":"shahednasser","description":"useDarkMode custom hook for react","archived":false,"fork":false,"pushed_at":"2023-03-05T22:06:48.000Z","size":1345,"stargazers_count":16,"open_issues_count":6,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T09:12:30.163Z","etag":null,"topics":["dark-mode","dark-theme","react","react-components","react-hooks","usedarkmode-hook"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/use-dark-mode-hook","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/shahednasser.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":"2021-03-04T20:06:46.000Z","updated_at":"2025-02-12T22:34:53.000Z","dependencies_parsed_at":"2025-03-10T22:32:29.032Z","dependency_job_id":"fdd09008-ce1d-4989-a1d5-0f9ac0a43da4","html_url":"https://github.com/shahednasser/use-dark-mode-hook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shahednasser/use-dark-mode-hook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahednasser%2Fuse-dark-mode-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahednasser%2Fuse-dark-mode-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahednasser%2Fuse-dark-mode-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahednasser%2Fuse-dark-mode-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shahednasser","download_url":"https://codeload.github.com/shahednasser/use-dark-mode-hook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahednasser%2Fuse-dark-mode-hook/sbom","scorecard":{"id":815150,"data":{"date":"2025-08-11","repo":{"name":"github.com/shahednasser/use-dark-mode-hook","commit":"f7e3ece699e457365fb595353e01d75f6fe078a8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"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":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","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":"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":"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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":"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":"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":"Vulnerabilities","score":0,"reason":"19 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T14:07:44.656Z","repository_id":38399058,"created_at":"2025-08-23T14:07:44.656Z","updated_at":"2025-08-23T14:07:44.656Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29995021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"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":["dark-mode","dark-theme","react","react-components","react-hooks","usedarkmode-hook"],"created_at":"2024-10-03T16:26:14.980Z","updated_at":"2026-03-02T07:32:48.977Z","avatar_url":"https://github.com/shahednasser.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-dark-mode-hook\n\n![Small!](https://img.shields.io/bundlephobia/min/use-dark-mode-hook)\n\nA simple library to add dark mode functionality to your React projects!\n\n![Demo](./demo.gif)\n\nThis library provides a custom hook `useDarkMode` and a button toggler component `DarkModeToggler`. You can use them together or use a different button toggler component. However, this library does **not** provide any styling regarding dark and light mode. You have to do that yourself.\n\nBy default, `useDarkMode` will apply either `dark` or `light` class to the `body` of the document based on the choice of the user.\n\n## Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [useDarkMode + DarkModeToggler](#usedarkmode--darkmodetoggler)\n- [useDarkMode hook](#usedarkmode-hook)\n    - [Options](#options)\n- [DarkModeToggler](#darkmodetoggler)\n    - [Options](#options-1)\n- [Attribution](#attribution)\n- [License](#license)\n\n## Installation\n\nin your terminal:\n\n```\nnpm i use-dark-mode-hook\n```\n\n## Usage\n\n### useDarkMode + DarkModeToggler\n\nTo use both the functionality and UI (more details about the options of each in below sections):\n\n```js\nimport useDarkMode, { DarkModeToggler } from 'use-dark-mode-hook'\n\nfunction MyComponent () {\n    const [isDarkMode, toggleDarkMode] = useDarkMode()\n\n    return (\n        \u003cDarkModeToggler \n            isDarkMode={isDarkMode} \n            toggleDarkMode={toggleDarkMode}\n            buttonClassName=\"some-classes\"\n        /\u003e\n    )\n}\n```\n\n### useDarkMode hook\n\n```js\nimport useDarkMode from 'use-dark-mode-hook'\n\nfunction myComponent (props) {\n    const [isDarkMode, toggleDarkMode] = useDarkMode()\n\n    //do something with it\n}\n```\n\n**isDarkMode**: boolean state for whether dark mode is chosen or not\n**toggleDarkMode**: function that takes boolean value for whether dark mode should be enabled or not. Use this to change the user's preference (dark or light mode).\n\n#### Options\n\nYou can pass to `useDarkMode` the following options:\n\n| Name           | Type    | Description                                                     | Default |\n| -------------- | ------- | --------------------------------------------------------------- | ------- |\n| initialValue   | boolean | should it initially be dark                                     | false   |\n| darkModeClass  | string  | the class that should be given when dark mode                   | dark    |\n| lightModeClass | string  | the class that should be given when light mode                  | light   |\n| element        | string  | the selector of the element that the class should be applied to | body    |\n| debug          | boolean | should debug messages be shown in the console                   | false   |\n\n```js\nuseDarkMode({\n    initialValue: false,\n    darkModeClass: 'dark',\n    lightModeClass: 'light',\n    element: 'body'\n})\n```\n\n\n### DarkModeToggler\n\n```js\nimport { DarkModeToggler } from 'use-dark-mode-hook'\n\nfunction MyComponent () {\n    //some code\n\n    function toggleDarkMode (checked) {\n        //logic to toggle dark mode\n    }\n\n    return (\n        \u003cDarkModeToggler isDarkMode={value} toggleDarkMode={toggleDarkMode} /\u003e\n    )\n}\n```\n\nIf you use the button only for toggling dark mode, you need to pass it the following parameters:\n\n#### Options\n\n| Name            | Type             | Description                                                    |\n| --------------- | ---------------- | -------------------------------------------------------------- |\n| isDarkMode      | boolean          | Whether it's currently dark or light                           |\n| toggleDarkMode  | Function         | The function that will handle the change of login between dark |\n|                 |                  | and light mode. Takes boolean as parameter for whether dark is |\n|                 |                  | enabled or not.                                                |\n| buttonClassName | string(optional) | custom class to assign to button                               |\n\n\n---\n\n## Attribution\n\nIcons from [Feather](https://feathericons.com/).\n\n---\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahednasser%2Fuse-dark-mode-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshahednasser%2Fuse-dark-mode-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahednasser%2Fuse-dark-mode-hook/lists"}