# Different CSS changes for different color schemes

**URL:** https://meta.discourse.org/t/different-css-changes-for-different-color-schemes/282436
**Category:** Development
**Tags:** css
**Created:** [October 16, 2023, 7:17pm UTC](https://meta.discourse.org/t/different-css-changes-for-different-color-schemes/282436 "2023-10-16T19:17:55Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [October 17, 2023, 1:56pm UTC](https://meta.discourse.org/t/different-css-changes-for-different-color-schemes/282436/4 "2023-10-17T13:56:59Z")

</div>

> [@Renato\_Mendes](#):
>
> As I’ve been able to understand so far, any change in CSS is applied to both light and dark mode, which doesn’t make much sense.

If I understand the issue well, there’s a specific thing to do for this.

> [@Update themes and plugins to support automatic dark mode](https://meta.discourse.org/t/update-themes-and-plugins-to-support-automatic-dark-mode/161595/5):
>
> Great question, I tried this and noticed that we didn’t properly support using background images or theme variables in the special color definitions stylesheet. So I made some fixes in core, and you should be able to do this now (make sure you pull the latest core). So, if you have two images in your theme or theme component, with SCSS vars of $bg-light and $bg-dark respectively, you can add this to your color\_definitions.scss stylesheet: $bg: url(dark-light-choose($bg-light, $bg-dark)); :ro…

I’ve been working on a guide about this, but I’m struggling a bit to merge information so it’s clear enough to directly use the information in a theme, but still explains underlying technical stuff.

To explain how to do it the most clearly as I can…

I suggest you create a theme locally (using [Install the Discourse Theme CLI console app to help you build themes](https://meta.discourse.org/t/install-the-discourse-theme-cli-console-app-to-help-you-build-themes/82950) will help).  
Then, create a `common/color_definitions.scss` file in your theme, in which you write:

```scss
$my-color: dark-light-choose(#FC3468, #FF93AC);

:root {
  --my-color: #{$my-color};
}

```

Then, in `common/common.scss`, you can make use of the variable like this:

```scss
h1 {
  color: var(--my-color);
}

```

It will automatically pick the right color when in dark or light mode.

---

_[View the full topic](https://meta.discourse.org/t/different-css-changes-for-different-color-schemes/282436)._
