{"id":19896408,"url":"https://github.com/joserfelix/react-toggle-dark-mode","last_synced_at":"2025-04-05T05:08:25.455Z","repository":{"id":37016816,"uuid":"279499334","full_name":"JoseRFelix/react-toggle-dark-mode","owner":"JoseRFelix","description":"🌃 A sleek dark mode toggle button for React.","archived":false,"fork":false,"pushed_at":"2023-03-05T05:45:03.000Z","size":2005,"stargazers_count":184,"open_issues_count":34,"forks_count":16,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T04:09:00.394Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://react-toggle-dark-mode.netlify.app/","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/JoseRFelix.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":"2020-07-14T06:15:32.000Z","updated_at":"2025-03-19T10:47:50.000Z","dependencies_parsed_at":"2024-06-18T14:08:19.556Z","dependency_job_id":"209ec7a3-30c5-4494-a361-f802def16952","html_url":"https://github.com/JoseRFelix/react-toggle-dark-mode","commit_stats":{"total_commits":20,"total_committers":5,"mean_commits":4.0,"dds":"0.44999999999999996","last_synced_commit":"91b30e5ccf63126cbbd8abaae89282d32770e653"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoseRFelix%2Freact-toggle-dark-mode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoseRFelix%2Freact-toggle-dark-mode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoseRFelix%2Freact-toggle-dark-mode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoseRFelix%2Freact-toggle-dark-mode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoseRFelix","download_url":"https://codeload.github.com/JoseRFelix/react-toggle-dark-mode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289428,"owners_count":20914464,"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":[],"created_at":"2024-11-12T18:39:18.377Z","updated_at":"2025-04-05T05:08:25.433Z","avatar_url":"https://github.com/JoseRFelix.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003eReact Toggle Dark Mode\u003c/h1\u003e\n\u003c/div\u003e\n\u003cp\u003e\n  \u003ca href=\"https://www.npmjs.com/package/react-toggle-dark-mode\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Version\" src=\"https://img.shields.io/npm/v/react-toggle-dark-mode.svg\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/node-%3E%3D10-blue.svg\" /\u003e\n  \u003ca href=\"#\" target=\"_blank\"\u003e\n    \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" /\u003e\n  \u003c/a\u003e \n  \u003ca href=\"http://makeapullrequest.com\" target=\"_blank\"\u003e\n    \u003cimg alt=\"PRs Welcome\" src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\" /\u003e\n  \u003c/a\u003e\n  \u003cimg alt=\"Bundle size\" src=\"https://badgen.net/bundlephobia/minzip/react-toggle-dark-mode\" /\u003e \n\u003c/p\u003e\n\n\u003e 🌃 Animated dark mode toggle as seen in blogs!\n\n![Interactive sun and moon transition](./docs/demo.gif)\n\n## Prerequisites\n\n- node \u003e=10\n\n## Installation\n\n```shell\nnpm i react-toggle-dark-mode\n```\n\nor with Yarn:\n\n```shell\nyarn add react-toggle-dark-mode\n```\n\n## Usage\n\n```jsx\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { DarkModeSwitch } from 'react-toggle-dark-mode';\n\nconst App = () =\u003e {\n  const [isDarkMode, setDarkMode] = React.useState(false);\n\n  const toggleDarkMode = (checked: boolean) =\u003e {\n    setDarkMode(checked);\n  };\n\n  return (\n    \u003cDarkModeSwitch\n      style={{ marginBottom: '2rem' }}\n      checked={isDarkMode}\n      onChange={toggleDarkMode}\n      size={120}\n    /\u003e\n  );\n};\n```\n\n## API\n\n### DarkModeSwitch\n\n#### Props\n\n| Name                | Type                         | Default Value                   | Description                               |\n| ------------------- | ---------------------------- | ------------------------------- | ----------------------------------------- |\n| onChange            | \\(checked: boolean\\) =\u003e void |                                 | Event that triggers when icon is clicked. |\n| checked             | boolean                      | false                           | Current icon state.                       |\n| style               | Object                       |                                 | CSS properties object.                    |\n| size                | number                       | 24                              | SVG size.                                 |\n| animationProperties | Object                       | defaultProperties \\(see below\\) | Override default animation properties.    |\n| moonColor           | string                       | white                           | Color of the moon.                        |\n| sunColor            | string                       | black                           | Color of the sun.                         |\n\n### Default Animation Properties\n\n```javascript\nconst defaultProperties = {\n  dark: {\n    circle: {\n      r: 9,\n    },\n    mask: {\n      cx: '50%',\n      cy: '23%',\n    },\n    svg: {\n      transform: 'rotate(40deg)',\n    },\n    lines: {\n      opacity: 0,\n    },\n  },\n  light: {\n    circle: {\n      r: 5,\n    },\n    mask: {\n      cx: '100%',\n      cy: '0%',\n    },\n    svg: {\n      transform: 'rotate(90deg)',\n    },\n    lines: {\n      opacity: 1,\n    },\n  },\n  springConfig: { mass: 4, tension: 250, friction: 35 },\n};\n```\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://jfelix.info\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/21092519?s=460\u0026u=55be9996a2652c79880c62ad50d06e17639456e8\u0026v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJose Felix\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/JoseRFelix/react-toggle-dark-mode/commits?author=JoseRFelix\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/JoseRFelix/react-toggle-dark-mode/commits?author=JoseRFelix\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/JoseRFelix/react-toggle-dark-mode/commits?author=JoseRFelix\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e    \n  \u003c/tr\u003e  \n\u003c/table\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://allcontributors.org) specification.\nContributions of any kind are welcome!\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoserfelix%2Freact-toggle-dark-mode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoserfelix%2Freact-toggle-dark-mode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoserfelix%2Freact-toggle-dark-mode/lists"}