by clemens (24.03.2023)

How to use the users preferred color scheme on your website

tl;dr

In css, you can use the users color scheme by simply setting the color-scheme on the :root element:

:root {
  color-scheme: light dark;
}

Thanks to Jim Nielsen where I found about this