If you haven’t heard about the View Transitions API, it’s a new API that provides a mechanism for easily creating animated transitions between different website views. There are a few articles on the web about it already, here are some:
- MDN Web Docs · View Transitions API
- Chrome for Developers · Smooth transitions with the View Transition API
- Astro Docs · View Transition
Since Safari will soon join the Chromium browser family to support the View Transitions API in version 18, so let’s use its magic with the theme transition animation.
This animation takes inspiration from @hooray’s snippets with some minor tweaks to avoid comflicting with Astro’s View Transitions feature. You can find my implementation at ThemeToggle.vue, with some additional CSS rules as shown below:
Feel free reach out if you have any suggestions. But now it’s your turn to have fun with it!