Simple websites are better than beautiful ones. I'll repeat that for the folks in the back. Simple websites are better than beautiful ones. Let me be clear what I mean by a simple website. I don't mean a Wordpress site with a minimalist theme. I also don't mean a Substack …
I've been saying this for years. My site only has a few lines of javascript. the rest is pure html and css, and it's very simple. https://tylerthrailkill.com
There was a thread elsewhere asking whether a toggle should show current state or the state desired. There was enough disagreement that it quickly became apparent that, whatever else the toggle does, there should be something external to the toggle showing the possible states, indicating which way to move the toggle regardless of toggle appearance.
The disagreement was actually all over whether the question was about a switch or a button, and so some people were answering as though it was a switch, and some people were answering as though it was a button - switches and buttons do indeed have opposite approaches usually (a switch usually shows the current state - such as "on" - but a button shows what action will be triggered by pressing it, such as "play").
It really depends on the type of control and what it's controlling. As this is a switch, you'd expect the current state to be what's shown on the same side as the slider-- in this case, the slider is a sun in dark mode and a moon in light mode, which is the opposite way.
I've wondered what this problem was for years but never cared to figure it out, because it always resolved after the first button press (just refresh the page and it all works properly). turns out it is something wrong with my use of local storage to save your theme state. if you don't have the key in local storage then it does what you mentioned. I just need to switch this to prefers-color-scheme anyway.
It works if you visited the website already but the first time it breaks: reloading fixes this while emptying the caches breaks it again. As another user pointed out the first click after emptying the cache doesn’t do anything at all even though the animation plays out just fine
EDIT: I’m on safari ios, latest stable (17.3.1 if I’m not mistaken)
In dark mode you press it to go light mode, and in light mode you press it to go dark mode, but yeah, strictly speaking should've used a button rather than a switch for that usage.