{"id":22147757,"url":"https://github.com/rudrodip/theme-toggle-effect","last_synced_at":"2025-04-07T14:11:31.642Z","repository":{"id":245694694,"uuid":"818981073","full_name":"rudrodip/theme-toggle-effect","owner":"rudrodip","description":"theme toggle effect using view transitions api","archived":false,"fork":false,"pushed_at":"2024-08-20T04:26:50.000Z","size":1814,"stargazers_count":361,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T13:15:39.209Z","etag":null,"topics":["theme-toggle","view-transitions-api"],"latest_commit_sha":null,"homepage":"https://theme-toggle.rdsx.dev","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rudrodip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-06-23T12:39:25.000Z","updated_at":"2025-03-21T09:46:27.000Z","dependencies_parsed_at":"2024-06-23T14:24:06.375Z","dependency_job_id":"3f13baa9-7480-486f-a9dc-a0df3f36e8db","html_url":"https://github.com/rudrodip/theme-toggle-effect","commit_stats":null,"previous_names":["rudrodip/theme-toggle-effect"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rudrodip%2Ftheme-toggle-effect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rudrodip%2Ftheme-toggle-effect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rudrodip%2Ftheme-toggle-effect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rudrodip%2Ftheme-toggle-effect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rudrodip","download_url":"https://codeload.github.com/rudrodip/theme-toggle-effect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247666008,"owners_count":20975787,"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":["theme-toggle","view-transitions-api"],"created_at":"2024-12-01T23:20:45.508Z","updated_at":"2025-04-07T14:11:31.623Z","avatar_url":"https://github.com/rudrodip.png","language":"HTML","readme":"# Theme toggle effect\n\nHere's how we can create theme toggle effect using view transitions api\n\nThis is literally the two lines of js you need\n\n```js\nif (!document.startViewTransition) switchTheme()\ndocument.startViewTransition(switchTheme);\n```\n\nThen you can write your css as you wish to\n\nFor example\n\n```css\n::view-transition-group(root) {\n  animation-timing-function: var(--expo-out);\n}\n\n::view-transition-new(root) {\n  mask: url('data:image/svg+xml,\u003csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 40 40\"\u003e\u003cdefs\u003e\u003cfilter id=\"blur\"\u003e\u003cfeGaussianBlur stdDeviation=\"2\"/\u003e\u003c/filter\u003e\u003c/defs\u003e\u003ccircle cx=\"20\" cy=\"20\" r=\"18\" fill=\"white\" filter=\"url(%23blur)\"/\u003e\u003c/svg\u003e') center / 0 no-repeat;\n  animation: scale 1s;\n}\n\n::view-transition-old(root),\n.dark::view-transition-old(root) {\n  animation: none;\n  z-index: -1;\n}\n.dark::view-transition-new(root) {\n  animation: scale 1s;\n}\n\n@keyframes scale {\n  to {\n    mask-size: 200vmax;\n  }\n}\n```\n\nThis will create a nice circular transition effect when you switch themes.\n![theme-toggle](.github/assets/vta.gif)\n\nFor more examples, visit [theme-toggle.rdsx.dev](https://theme-toggle.rdsx.dev)\n\nDon't forget to star the repo if you like it\n\nFollow me on [x (twitter)](https://x.com/rds_agi) \u0026 [github](https://github.com/rudrodip)\n","funding_links":[],"categories":["HTML"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frudrodip%2Ftheme-toggle-effect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frudrodip%2Ftheme-toggle-effect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frudrodip%2Ftheme-toggle-effect/lists"}