logoalt Hacker News

azangruyesterday at 1:24 PM3 repliesview on HN

> Similarly for header-navigation and theme-toggle

The theme toggle has three states. How do you model this with a checkbox?


Replies

bmachoyesterday at 2:18 PM

It's possible to have a 3-states CSS switch/slider that controls site theme. Google it or ask AI assistant.

Elfeneryesterday at 2:29 PM

Why does a site even need a light/dark toggle, when you can just use prefers-color-scheme in CSS, and the user can select that in their browser settings?

(Also, technically, alternative stylesheets can be defined in HTML, except every browser except Firefox removed it: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...)

show 4 replies
jarek83yesterday at 1:56 PM

It could be done with :indeterminate state (so key in a cookie would be absent or removed when switching), but I'd probably would do it with radios instead

show 1 reply