light-dark mode with JS

 


This is a full website demo for light dark mode. 

There is also a simple ligh-dark mode with sass demo

CODE SEPERATE:

HTML

The toggle is at the right corner with fixed position.

Four sections with smooth scrolling.


Home: title and a button

About:three toggle images and title

Menu:icons and a menu ,just for demo

Contact: icon and form 

CSS


Set the two mode color sets.


toggle button is a checkbox .


A gradient background on the background image.

Set the default color of light mode.




JAVASCRIPT


Get the DOM 


Check the theme is light or dark,then run the toggleDarkLightMode().


If mode is light, change the nav backgound color and images links.



If the localStorage theme sets to dark , it will record in the localStorage.

CODE Github

Popular posts from this blog

Fancyapps — easily build overlay windows with carousel

Thoughts about Progressive Web App

Meet Mantine: A TS-Based Open-Source React Components Library