How can we detect dark mode in CSS and JavaScript? How can we manually override it with a toggle button? And how do we save our setting in localStorage? In this quick tutorial, we look into detecting dark mode in CSS and JavaScript and then create a toggle button with SVG to override the default behavior.
Source code: https://github.com/HunorMarton/gorillas
Learn more about SVGs: https://svg-tutorial.com/
𝕏 — / hunorborbely
Buy Me a Coffee: https://www.buymeacoffee.com/hunor
Website — http://hunormarton.github.io
And more — https://bio.link/hunor
0:00 - Introduction
0:22 - Handling dark mode in CSS
2:06 - Sun Icon with SVG
4:37 - Detecting dark mode in JavaScript
6:33 - Moon Icon with SVG
9:27 - Toggle dark move with JavaScript
11:59 - Saving the user setting to localStorage
13:03 - Next Steps
#javascript #darkmode #svg
Nesta página do site você pode assistir ao vídeo on-line How to Handle Dark Mode with CSS and JavaScript - SVG Toggle Button Tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Hunor Márton Borbély 07 Março 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 3,848 vezes e gostou 91 espectadores. Boa visualização!