:: Re: [DNG] Darkmode, on Devuan homep…
Startseite
Nachricht löschen
Nachricht beantworten
Autor: Amin Bandali
Datum:  
To: Steve Litt
CC: dng
Betreff: Re: [DNG] Darkmode, on Devuan homepage?
Hello,

FYI adding support for light/dark mode could in principle be as easy
as adding the following to the HTML <head>:

    <meta name="color-scheme" content="light dark">


This will tell browsers that support this (e.g. Firefox or Chromium)
to use a light or dark theme based on the user preference.
These days, both Firefox and Chromium have fairly decent colours
defined for light and dark mode out of the box, so you may not even
need to make much changes in your CSS.

That said, you *can* set styles based on whether light or dark mode is
active using a media query like so:

    body { background-color: #edffed }


    @media (prefers-color-scheme: dark) {
      body { background-color: #222 }
    }


With the above, we set the normal background-color for body to a
bright #edffed color, and if dark mode is active we use a dark #222
color instead.

You may find this MDN article useful:

https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-color-scheme

Hope this helps.