logoalt Hacker News

tasukiyesterday at 7:42 PM1 replyview on HN

Ah, you have a button for the toggle! Did you know that you can conform to the user's light/dark preference with CSS? Like this:

    :root { --varname: #FFE; }
    
    @media (prefers-color-scheme: dark) {
        :root { --varname: #022; }
    }
Edit: To expand on this, I dislike light/dark toggles. If I have dark mode on, seeing a bright screen and having to search for a toggle is jarring. Just show me the colours according to my preference!

Replies

aurahamyesterday at 9:06 PM

How can you detect the system preferences in the browser?

show 1 reply