Comment by kickingvegas

24 days ago

FYI, light-dark() in CSS is a thing now.

https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/V...

And `:prefers-color-scheme` has been supported by all major browsers for seven years.

  • Windows 3 through windows 7 had pervasive support for dark mode as long as application developers didn't custom paint their user interfaces. Application developers started out almost all supporting system colors and gradually over the next 25 years or so started implementing their own custom-drawn interfaces, accelerated by embedded IE/mshtml views and then later even more by Electron. This concluded with practically zero interfaces supporting the system color scheme.

    • Yeah but "dark mode" for Win3 through WinXP was primarily to support passive matrix LCDs, which required inverted color schemes to appear with enough contrast to read. That is why the built-in "high contrast" color schemes look so aggressively awful.

      1 reply →

    • Yeah, when dark mode became "a thing" my first reaction was "...didn't we have this already?"

      I was a theme junkie back in Windows 98 times, but stopped bothering since it became increasingly clear that Microsoft was not really interested in supporting them after XP.

    • Custom painting isn't the only thing that broke it. You can customize the style (colors) of the native widgets to get a desired look but IIRC you could choose from system colors (follows the theme/mode automatically) or exact colors. Some applications used a mix of them which made the UI look awful if you switched away from whatever the default theme was.

    • Maybe the apps with the windows classic interface. I remember it starting mainly around the XP days when alls started designing these super ugly (but trendy at the time) rounded corner and bubbly interfaces that were static in resolution and colour scheme.

      1 reply →

  • And broken in Chrome since the beginning:

    https://issues.chromium.org/issues/366412383

    • I wouldn't call this part of the situation a bug. I'm sure everyone has their own opinion about which is the "right" way to handle a mismatch of OS level preference and browser level theme though.

      The underlying problem is Chrome exposes no (normal) setting to override the OS level setting at all, not necessarily that the preference shall always follow the browser's theme specifically.

      2 replies →

    • This issue is related to appearance setting inside Chrome itself (which sets Chrome's appearance, not how it should work with websites AFAIK). The core feature of prefers-color-scheme (following the OS-level setting) is working as intended.

      4 replies →

    • So I guess it hasn’t been supported anywhere in a sense.

      Safari and Firefox are pretty small.

It makes me so angry that they named the CSS function `light-dark` instead of leaving the door open to allowing generic user- or site-specified color schemes. I mean it was right there in all the other mechanisms around this feature, they just had to read and think about why these are structured the way they are, and why "light" and "dark" were always values and not keywords in all of these..:

    - <meta name="color-scheme" content="light dark">
    
    - :root { color-scheme: light dark }

    - @media (prefers-color-scheme: dark) { }

    - <picture><source media="(prefers-color-scheme: dark)">

.... and then we've got `light-dark()`, the goofy looking dragon hanging out to the side of these majestic, forward-thinking parts of the specification.

Did they not look at the prior art and notice that "one of these things is not like the other?" All the other pieces of this puzzle, conceivably, could have one day had something like `:root { color-scheme: halloween }` or `@media (prefers-color-scheme: supercontrast)` but no, we're just going to cement `light-dark()` as the only two possible color schemes we'd ever want to switch between forever.

  • Color schemes (luminance modes) and color themes (aesthetic styles) are not the same thing. Halloween theme can have light and dark schemes.

    Also, prefers-contrast media query exists, which can be used in combination with the luminance modes (color-scheme): halloween-light, halloween-dark, halloween-light-high-contrast, halloween-dark-high-contrast.

    https://news.ycombinator.com/item?id=47832705

  • It’s always irked me that light and dark are given privileged positions in the namespace. They’re just themes (or schemes if you like), like all the other possible themes.

  • IMO this would have been the perfect way to ensure the feature won't be useful for anyone. You need buy-in from both developers and users for something like this. Developing one alternate color scheme that everyone supports is a thousand times easier to justify than developing n alternate color schemes that most people don't care about.

    And by naming the function `light-dark()`, they explicitly left the door open to introduce something like you suggest in the future. Had they already named the function something more generic, it would limit the flexibility of any future API!

  • I actually like `light-dark`. It's a shortcut to something that can be done more comprehensively with other, longer forms, but tailored to the most common (by far!) use case. It's a wart in the spec (specific color schemes as keywords) so that we can remove the warts in our code (media query blocks in CSS).

    It's not like CSS was pure and elegant to begin with, so why not add an oddity that is actually useful?

  • I’m not sure what kind of function you’re asking for that would support arbitrary user-defined themes. With the if() function and/or @function declarations you could build pretty much any system you want for defining theme-specific values for arbitrary themes.