logoalt Hacker News

suprjamitoday at 2:00 AM5 repliesview on HN

Gimme a dark/light mode switch. CSS is allowed.


Replies

adzmtoday at 2:05 AM

Use a checkbox, d. Define vars for light mode. Override when checked for dark mode with body:has(#d:checked) and can include the dark mode media query too

zahlmantoday at 3:44 AM

See https://lyra.horse/blog/2025/08/you-dont-need-js/, via https://news.ycombinator.com/item?id=45056878 (which discussion contains some deeper explanation).

tisctoday at 7:47 AM

Why would you build a switch instead of relying on the user’s system settings? The only reason I can imagine is that your dark/light mode is not usable/readable so it forces the user to switch

show 3 replies
johnisgoodtoday at 2:02 AM

Checkbox and :checked are your friends.