I have implemented a night mode (or perhaps dark mode) toggle button located at the top-right corner of my webpage.
Here is a link to a perfect example showcasing what I am aiming for
However, unlike the provided link, I switch between night mode and light mode using the following code:
HTML I utilize a data-theme attribute to toggle between modes. (switching from night to light or light to night)
<body data-theme="">
<div class="toggle" id="switch" onclick="toggleDarkMode()"></div>
</body>
JS
function toggleDarkMode() {
var dataTheme = $('body').attr('data-theme');
if(dataTheme == 'dark') {
$('body').attr('data-theme', 'light');
} else {
$('body').attr('data-theme', 'dark');
}
};
I would appreciate any advice on how to implement a night mode toggle with an expanding circle animation using keyframes.
Thank you in advance!