Hi everyone!

Is there any action in OS than can retrieve the browsers default theme? i.e light or dark mode? 

I know you can use: @media (prefers-color-scheme: dark) to apply a theme, but this is not (yet) available on all browsers and I wanted something that could also be used to modify the favicon, hence the server action...


Hi,

Not an answer to your question but prefers-color-scheme is supported by al major browsers except IE.

See https://caniuse.com/#search=prefers-color-scheme

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi,

Not an answer to your question but prefers-color-scheme is supported by al major browsers except IE.

See https://caniuse.com/#search=prefers-color-scheme

Regards,

Daniel

Yes you are correct, i saw a print from that same website, which obv hasnt been updated since its a static picture and therefore i got the wrong idea. Nonetheless, and like you said, I still need a way to use it as a server action method. 

I saw this line to use for JS: window.matchMedia('(prefers-color-scheme: dark)').matches

I havent had time to try it yet, but I reckon I could convert the output of that JS to an OS variable. Whats your opinion on that?


For traditional web the rendering takes place on the server, so not sure you can achieve that without first have a page loaded in the browser, then doing another server call.

For reactive or mobile you can all do this client side.