ditdot-dev / dark-mode-example

Simple and fun dark-mode detection. JavaScript with a user mode toggle.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

toggle is not persistent state

bradholmes-studio opened this issue · comments

if toggled and the page changed the state resets to system preferences is it possible to add localStorage to this

Hi @bradholmes-studio,

yes, it is possible. Here is a link to our article Dark Mode - The prefers-color-scheme Website Tutorial and adding localStorage is described in the "How to Make Persistent User Choice Mode with JavaScript using localStorage" chapter.