The workshop’s sales card as a reversible cloth: write light-dark(), switch the OS and the theme button, the browser shows which argument it picked, and Mr…
Dark mode is standard now, but the old way (@media (prefers-color-scheme: dark)) writes every colour twice in two places: easy to forget one. light-dark() puts both in one declaration, and since it follows color-scheme, your site’s theme button only has to change one property. For old browsers, one fallback line above it.
light-dark() picks an argument by color-scheme, not by the OS, and never blends
light-dark() but the colours never switch The element (or an ancestor) needs color-scheme: light dark. Without it the scheme is normal (light) and light-dark() sticks to the first argument. Set it on :root.light-dark() blends two colours It is not color-mix(): it picks one. light-dark(red, blue) is red or blue, never purple.light-dark() follows the used color-scheme. Your button only writes data-theme on <html>, and the CSS is :root[data-theme="dark"] { color-scheme: dark; } (plus a light one). No colour needs rewriting.color-scheme. The key label on the table moves too.color-scheme from :root, then set the OS to dark The card stays light: its scheme is normal, so light-dark() keeps picking the first argument..promo dark on a light OS One color-scheme: dark line on .promo. The card stays light.data-theme that differs from the OS Pick "Theme button". :root[data-theme="dark"] { color-scheme: dark } beats the OS without changing a single colour.