Create HTML CSS Toggle Button
here is how you can create this toggle button using html ,css & Javascript
Create a toggle button in only 6 minutes
You don't know how to create a toggle button to switch from the dark mode and the light mode?🤔 See this tutorial !☺️
card structure and styling:
on this website we use only a simple design with html and css, because we want to focus on the javascript , we use only the h1 and a button and we give it a idtoggle-btn to use it in the Javascript .
Javascript Logic:
we use the const and we give it a name, we do the getElementById and we get the ('toggle-btn') , add a class on the classlist ('light'), we need to add a EventListener to the toggleBtn and we do a body.classlist.toggle('light') and we do the same for the dark, like this we got a good toggle-btn for your website, portfolio, landing page etc.