Hi guys, I've create a mini website with dark mode switch. For this, I used cookies to save the option the user chose. The best part of this method - when you scroll between pages, the chosen theme remains on those pages as well! Feel free to clone and examine it, and don't hesitate to use in your projects!
Credits to LS Graphics for Muir UI Kit I used for this website.