17:24
<annevk>
Domenic: that's a great thread <3; I'm on board
17:28
<Benny Powers>

hello! I'm thinking of making a proposal for a new web platform API that lets web developers imperatively set the prefers-color-scheme media query, or an allowlist of other keys.

something like

await navigator.setMedia('prefers-color-scheme', 'dark');

the case I have in mind is "toggle color scheme" buttons, which right now typically set a class on the body. This works, but leads to duplication of code, as users would have to

body {
  --my-theme-color: darkgrey;
}
@media(prefers-color-scheme: dark) {
  body {
    --my-theme-color: lightgrey;
  }
}
body.dark {
    --my-theme-color: lightgrey;
}

Is this something that WHATWG might consider? is it worth my time trying a formal proposal?

17:47
<TabAtkins>
Benny Powers: That's a CSSWG issue, actually. And as it so happens, I started a thread on this exact thing, for that exact use-case, a few days ago: https://github.com/w3c/csswg-drafts/issues/6517
17:48
<Benny Powers>
thank you, TabAtkins