Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark mode support #55

Open
huksley opened this issue Jul 20, 2022 · 3 comments
Open

Dark mode support #55

huksley opened this issue Jul 20, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@huksley
Copy link

huksley commented Jul 20, 2022

Is your feature request related to a problem? Please describe.
Lots of people prefer dark mode nowadays. Is there any predefined way to set colors to support dark mode?

Describe the solution you'd like
Preset values for variables for a dark mode and support for switching dark and light mode.

Describe alternatives you've considered
Picking color values myself but it might be difficult to pick right ones. Also using Dark mode browser extension.

@alvaromontoro
Copy link
Owner

Thanks for raising this issue (and sorry for the late reply).

I need to investigate the best way of doing this. In the meantime, the good news is that it is possible to have Almond.CSS working in light and dark mode in a relatively simple way:

  • Set the default colors using the the variables described in the README file.
  • Add a prefers-color-scheme rule with the dark/light values

It could be done like this on the document's <head>:

<link rel="stylesheet" href="almond.min.css" />
<style>
:root {
  --primaryH: 210;
  --primaryS: 50%;
  --primaryL: 40%;
  --primary-bg: #fff;
  /* ...rest of the variables/colors */
}

@media (prefers-color-scheme: dark) {
  :root {
    --primaryH: 110;
    --primaryS: 50%;
    --primaryL: 80%;
    --primary-bg: #fff;
    /* ...rest of the variables/colors */
  }
}
</style>

@alvaromontoro alvaromontoro added the enhancement New feature or request label Jan 13, 2023
@KoljaL
Copy link

KoljaL commented Jan 14, 2023

Great 😃
Please implement this

@tribut
Copy link

tribut commented Jul 21, 2023

I've tried to build a dark mode using this technique and its promising, but there are some roadblocks:

  • Some Elements are not styled (e.g. background of input and dialog appear to be always white)
  • --primary-light and similar would have to be inverted in meaning (i.e. --primary-light needs to be darker than --primary)
  • Icons are currently not affected by the color scheme. There are some tricks to color svg background-image, but I'm not sure how easy they would be to implement. Maybe something would be possible with :before and mask?

Maybe there is more, but that was the most noticeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants