Remix.run Logo
bmacho 13 hours ago

Darkmode toggle can be (and usually is) achieved by CSS.

Alifatisk 9 hours ago | parent [-]

And the state of it persist across page loads or tabs?

bmacho 9 hours ago | parent [-]

No. It might, depending on what your browser does, but it's not in the web standard.

But you can have a button that saves your state when you enable javascript, and doesn't save your state (but still works) when you disable javascript.

edit: I think it is possible to save your state on the second click. So the UX is: you have 3 options with a slide. You click one of them, the page theme changes, and the option icon becomes a padlock. You click on it again, and the option is saved.

It seems to be a limitation that without javascript a single click can't change a switch and do something else--make a request to set a cookie. But you can do changing style on first click, then setting a cookie on the second. Here's a demo (written by Claude) (it doesn't work without server, just the HTML part) https://jsfiddle.net/r134vgo7/3/