{"id":21071173,"url":"https://github.com/minhomega/react-theme-switch-animation","last_synced_at":"2025-05-16T05:31:22.127Z","repository":{"id":245804114,"uuid":"818908474","full_name":"MinhOmega/react-theme-switch-animation","owner":"MinhOmega","description":"React Theme Switch with smooth animation supports dark and light modes on NextJS, ReactJS, and more ...","archived":false,"fork":false,"pushed_at":"2025-04-20T06:37:48.000Z","size":417,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-09T00:12:55.170Z","etag":null,"topics":["animation-css","animation-effects","dark-theme","hook","nextjs","nextjs14-typescript","react-themes","reactjs","theme","typescript"],"latest_commit_sha":null,"homepage":"https://minhomega.github.io/react-theme-switch-animation/","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/MinhOmega.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2024-06-23T08:16:25.000Z","updated_at":"2025-04-23T07:42:42.000Z","dependencies_parsed_at":"2024-06-24T09:06:38.749Z","dependency_job_id":"93f20004-2452-45b0-a4e2-cfbb59a276b0","html_url":"https://github.com/MinhOmega/react-theme-switch-animation","commit_stats":null,"previous_names":["minhomega/react-theme-switch-animation"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MinhOmega%2Freact-theme-switch-animation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MinhOmega%2Freact-theme-switch-animation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MinhOmega%2Freact-theme-switch-animation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MinhOmega%2Freact-theme-switch-animation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MinhOmega","download_url":"https://codeload.github.com/MinhOmega/react-theme-switch-animation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254474098,"owners_count":22077214,"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":["animation-css","animation-effects","dark-theme","hook","nextjs","nextjs14-typescript","react-themes","reactjs","theme","typescript"],"created_at":"2024-11-19T18:50:19.277Z","updated_at":"2025-05-16T05:31:17.118Z","avatar_url":"https://github.com/MinhOmega.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003eReact Theme Switch Animation Hook\u003c/h1\u003e\n  \u003cp align=\"center\"\u003e\n  This package provides a hook for toggling dark mode in React applications with a smooth animation effect in TailwindCSS.\n  \u003c/p\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003e\n    \u003ca href=\"https://minhomega.github.io/react-theme-switch-animation/\" target=\"_blank\"\u003eLive code demo\u003c/a\u003e |\n    \u003ca href=\"https://github.com/minhomega/\" target=\"_blank\"\u003eHire me here\u003c/a\u003e\n  \u003c/strong\u003e\n\u003c/p\u003e\n\n## 🎥 Demo\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/c728d9b4-a546-4fda-9d1f-7f831317cb6b\"\u003e\n\u003c/p\u003e\n\n## 📝 Notes\n\n- The hook is only available in the browser environment. So if you use NextJS App router or any other framework that uses Server Components, you should use this hook in a Client Component by adding the directive [`use client`](https://react.dev/reference/react/use-client)\n- Currently works only if the project is using TailwindCSS\n- Ensure your project has the necessary TailwindCSS configuration for dark mode\n\n## 🚀 Features\n\n- Toggles dark mode with an animation effect.\n- Smooth animations for theme switching.\n- Uses React Hooks for state management.\n- Supports TypeScript for enhanced development experience.\n- Uses `localStorage` to persist the dark mode state across sessions.\n- Provides a React ref that can be attached to any component to trigger the mode change.\n\n## 📦 Installation\n\nInstall the package using npm or YARN:\n\n```bash\nnpm install react-theme-switch-animation\n```\n\nor\n\n```bash\nyarn add react-theme-switch-animation\n```\n\n## 📚 Usage\n\nHere’s how to use the `useModeAnimation` hook in your React component:\n\n```jsx\n'use client'\n\nimport React from 'react'\nimport { useModeAnimation } from 'react-theme-switch-animation'\n\nconst MyComponent = () =\u003e {\n  const { ref, toggleSwitchTheme, isDarkMode } = useModeAnimation()\n\n  return (\n    \u003cbutton ref={ref} onClick={toggleSwitchTheme}\u003e\n      Toggle Dark Mode (Currently {isDarkMode ? 'Dark' : 'Light'} Mode)\n    \u003c/button\u003e\n  )\n}\n\nexport default MyComponent\n```\n\n## 📚 API\n\n`useModeAnimation` accepts an optional `props` object with the following properties:\n\n| Property          | Type   | Default                         | Description                                |\n| ----------------- | ------ | ------------------------------- | ------------------------------------------ |\n| `duration`        | number | `750`                           | Duration of the animation in milliseconds. |\n| `easing`          | string | `\"ease-in-out\"`                 | CSS easing type for the animation.         |\n| `pseudoElement`   | string | `\"::view-transition-new(root)\"` | Pseudo-element used for the animation.     |\n| `globalClassName` | string | `\"dark\"`                        | Class name to apply to the root element.   |\n\nReturns an object containing:\n\n- `ref`: React ref for attaching to the component that will trigger the dark mode toggle.\n- `toggleSwitchTheme`: Function to toggle dark mode.\n- `isDarkMode`: Current state of dark mode (`true` for dark, `false` for light).\n\n## 📝 Requirements\n\n- React 16.8 or later (for Hooks support).\n- TypeScript for compiling the package during installation.\n\n## 🤝 Contributing\n\nContributions are welcome! Please open an issue or submit a pull request with your suggested changes.\n\n## 📜 License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminhomega%2Freact-theme-switch-animation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminhomega%2Freact-theme-switch-animation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminhomega%2Freact-theme-switch-animation/lists"}