# Dark/Light Mode Toggle

**URL:** https://meta.discourse.org/t/dark-light-mode-toggle/215585
**Category:** Theme component
**Tags:** deprecated, dark-mode-toggle
**Created:** [January 21, 2022, 6:50pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585 "2022-01-21T18:50:36Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [January 21, 2022, 6:50pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/1 "2022-01-21T18:50:36Z")

</div>

> [@](#):
>
> ⚠ this theme component has been deprecated. Please see [Dark/light mode toggle now available in core](https://meta.discourse.org/t/dark-light-mode-toggle-now-available-in-core/350991)

| | | |
| --- | --- | --- |
| :discourse2: | **Summary** | **Dark/Light Mode Toggle** adds a clickable toggle color scheme button in the hamburger menu. The toggle switches between a light or dark color scheme for one theme. |
| 🛠 | **Repository Link** | [https://github.com/discourse/discourse-color-scheme-toggle](https://github.com/discourse/discourse-color-scheme-toggle) |
| 📖 | **New to Discourse Themes?** | [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) |

Install this theme component

> [@](#):
>
> :discourse2: As this is an #official theme component maintained by the Discourse team, #Support, #Contribute > Bug, #Contribute > UX, and #Contribute > Feature requests can be made in the respective categories here on Meta, and tagged with the appropriate theme component tag. Click on a link below to get one started. 👍
> 
> [❓&nbsp; **Support**](https://meta.discourse.org/new-topic?category_id=6&tags=dark-mode-toggle "Ask for support on configuring and using Dark/Light Mode Toggle") [🐛&nbsp; **Bug**](https://meta.discourse.org/new-topic?category_id=1&tags=dark-mode-toggle "A bug report means something is broken, preventing normal/typical use of the theme component") [👀&nbsp; **UX**](https://meta.discourse.org/new-topic?category_id=9&tags=dark-mode-toggle "Discussion about the user interface of Dark/Light Mode Toggle, and how features are presented (including language and UI elements)") [💡&nbsp; **Feature**](https://meta.discourse.org/new-topic?category_id=2&tags=dark-mode-toggle "Discussion about how existing Dark/Light Mode Toggle features can be improved or enhanced, and how proposed new features could work")

### Features

This component allows a dark/light mode toggle icon on your Discourse forum. It will also automatically switch if you change your system OS to a mode other than your current color scheme.

You can choose to have the toggle display in the new Discourse Sidebar or in the header alongside other icons.

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/1/7/d170aad7bc2da6e5e8577657aa24c11a530ecf12.png)

#### Sidebar

![Kapture 2022-12-02 at 10.55.59](https://global.discourse-cdn.com/meta/original/4X/4/2/7/427841e02086eb49cd076dc04c1527991247951f.gif)

#### Header

![Kapture 2022-12-02 at 10.57.54](https://global.discourse-cdn.com/meta/original/4X/5/d/2/5d27adb31149c78d28b8b3a867fe63eab575d4a3.gif)

### Important Steps

For this to work properly, at least 2 color scheme choices need to be enabled in your `/admin/customize/colors` area. At least two colors need to have `color scheme can be selected by users` enabled.

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/7/b70d149b335128a5f71914db3f703def1f48376b.png)

A default color scheme needs to be set for dark mode: `/admin/site_settings/category/basic?filter=dark`

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/e/ce09baa36606de7f3d9fcfc8f8e0b986eb4cc783.png)

Once this is done, users should be able to choose between two color schemes as their `light` and `dark` preferences in their user preferences interface menu.

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/8/184e79ce3851b9feb965117b68a97e5e7de00b93.png)

### Settings

| Name | Descriptions |
| --- | --- |
| svg icons | |
| add color scheme toggle to header | Add color scheme toggle button to site header |

| Translation | Default |
| --- | --- |
| toggle\_button\_title | Toggle color scheme |

> :discourse2: **Hosted by us?** Theme components are available to use on our Standard, Business, and Enterprise plans.

> Last edited by @Osama 2025-02-07T02:35:50Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![chrisbagsrocks](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbagsrocks/32/248579_2.png) [@chrisbagsrocks](https://meta.discourse.org/u/chrisbagsrocks)
#### Post date: [February 3, 2022, 1:00am UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/12 "2022-02-03T01:00:38Z")

</div>

Does this only work with the user input via going to their preferences and enabling it? Would be a lot better if It could be a site wide implementation rather than on a user to user base.

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [February 3, 2022, 3:20pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/13 "2022-02-03T15:20:49Z")

</div>

An admin would enable this component for the entire site.

From there, depending on what the admin who set up the component has set, the toggle will either be in the user hamburger menu, or on the header of the forum. All users can use this once it has been enabled by an admin.

---

<div class="post-metadata">

### Author: ![chrisbagsrocks](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbagsrocks/32/248579_2.png) [@chrisbagsrocks](https://meta.discourse.org/u/chrisbagsrocks)
#### Post date: [February 3, 2022, 6:31pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/14 "2022-02-03T18:31:24Z")

</div>

Sorry, I don’t think I was clear with my question. By looking at your installation tutorial, After it is enabled on the admin side either in hamburger menu or on the header, it looks like each individual user has to go to their preferences and enable/add the light/dark color schemes. Otherwise it does not work for a new user / someone not logged in. So my question is:  
Is it possible to implement the color scheme site wide rather than on a user-to-user basis.  
Your photo is below for reference

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/5/b58ebd3d5d1bf8c87da6d2000d64bf8b31506fb3.png)

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [February 3, 2022, 6:37pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/15 "2022-02-03T18:37:04Z")

</div>

I believe a light scheme and dark scheme will be auto assigned once an admin enables it. From there, a user can edit which dark and light color schemes are used as their personal preference.

You may have to also add a selection here `/admin/site_settings/category/basic?filter=dark`

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/e/ce09baa36606de7f3d9fcfc8f8e0b986eb4cc783.png)

I have updated the instructions to reflect this addition. Sorry for the confusion!

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [February 5, 2022, 5:32am UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/16 "2022-02-05T05:32:07Z")

</div>

It seems doesn’t work correctly when the default color scheme is dark. How can we adapt this?

When the default color scheme is dark, toggle does not work unless a user has select light color scheme from the interface preferences.

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [February 7, 2022, 3:34pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/17 "2022-02-07T15:34:03Z")

</div>

Hmmm, I believe this is happening because I am checking for `prefers-dark` user scheme settings based on the browser and system settings.

Can you look at your inspector console and see if anything is coming up when trying to use the toggle?

I may have to look into this.

---

<div class="post-metadata">

### Author: ![poyrazdursuncan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/poyrazdursuncan/32/204976_2.png) [@poyrazdursuncan](https://meta.discourse.org/u/poyrazdursuncan)
#### Post date: [February 9, 2022, 7:44pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/18 "2022-02-09T19:44:16Z")

</div>

> Warnings at [domain.com/logs](http://domain.com/logs) ;

```plaintext
Dark-Light Toggle theme/component is throwing errors

initialize@https://develcoder.com/theme-javascripts/1d5669cf8344e0837406cef0be37bb086b5968f5.js?__ws=develcoder.com:153:73

initialize@https://develcoder.com/assets/application-01686ed6ee22a989833acbbce970ba63.js:1:11855

https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:268273

each@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:429458

walk@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:428478

each@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:427828

topsort@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:427874

_runInitializer@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:268501

runInstanceInitializers@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:268222

_bootSync@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:252462

didBecomeReady@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:257791

invoke@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:418024

flush@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:417018

flush@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:418946

_end@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:424401

end@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:421081

_run@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:36:424937

u@https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:26:26509

https://develcoder.com/assets/vendor-0cc77969943fbfe61f9ee3bae9d7291d.js:26:26807

```

---

<div class="post-metadata">

### Author: ![Mr.X\_Mr.X](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mr.x_mr.x/32/126610_2.png) [@Mr.X\_Mr.X](https://meta.discourse.org/u/Mr.X_Mr.X)
#### Post date: [February 9, 2022, 7:46pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/19 "2022-02-09T19:46:22Z")

</div>

Same here. Dark light component throwing errors.

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [February 9, 2022, 9:33pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/20 "2022-02-09T21:33:04Z")

</div>

> [@poyrazdursuncan](#):
>
> `Dark-Light Toggle theme/component is throwing errors`

> [@Mr.X\_Mr.X](#):
>
> Same here. Dark light component throwing errors.

Hmmm… not sure where that is coming from as I have no code that should send that out. The only communication I have for an error is here:

[https://github.dev/discourse/discourse-color-scheme-toggle/blob/3474a80d81d89f1264be5d55652dc65b5aea68e2/javascripts/discourse/initializers/dark-light-toggle-hamburger.js#L56-L59](https://github.dev/discourse/discourse-color-scheme-toggle/blob/3474a80d81d89f1264be5d55652dc65b5aea68e2/javascripts/discourse/initializers/dark-light-toggle-hamburger.js#L56-L59)

Can you link to your site here if possible? Is your instance up to date?

---

<div class="post-metadata">

### Author: ![Arta\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arta_s/32/537495_2.png) [@Arta\_S](https://meta.discourse.org/u/Arta_S)
#### Post date: [February 15, 2022, 11:37am UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/21 "2022-02-15T11:37:36Z")

</div>

Hello,

I have an issue. After adding the theme, the toggle icons are not added in the hamburger menu. They dont even exist in bare code. Also you [demo here](https://discourse.jordanvidrine.com/) the buttons dont work. meaning they dont switch between light and dark themes.

Anyone else having the same issue?

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [February 15, 2022, 3:44pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/22 "2022-02-15T15:44:41Z")

</div>

Can you check the dev tools console and see if anything shows up related to this? I am seeing the icons work fine on the demo site.

---

<div class="post-metadata">

### Author: ![Arta\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arta_s/32/537495_2.png) [@Arta\_S](https://meta.discourse.org/u/Arta_S)
#### Post date: [February 16, 2022, 9:43am UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/23 "2022-02-16T09:43:10Z")

</div>

Here is the video:

My main issue is that on my forum, I don’t even see these options in hamburger menu:

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/8/e88d388a1de45811e2ee9bcd391729c9c8277e1c.png)

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [February 16, 2022, 2:43pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/26 "2022-02-16T14:43:58Z")

</div>

You do not have the `console` tab open in your screen cast, so it is hard to see if any errors are taking place.

Have you made sure to follow each step in the original post on this topic?

at least 2 color scheme choices need to be enabled in your `/admin/customize/colors` area  
 A dark theme needs to be enabled at: `/admin/site_settings/category/basic?filter=dark`

And do you, as a user, have two color schemes selected, one for light, and one for dark, in your user preferences?

---

<div class="post-metadata">

### Author: ![Arta\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arta_s/32/537495_2.png) [@Arta\_S](https://meta.discourse.org/u/Arta_S)
#### Post date: [February 17, 2022, 8:36am UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/27 "2022-02-17T08:36:17Z")

</div>

> [@jordan.vidrine](#):
>
> Have you made sure to follow each step in the original post on this topic?

Hello,

Yes this was correctly executed. Today everything is showing correctly. This was due to cookies. It was odd that on other browsers (where I never visited the forum) it was showing missing as well. Now everything is correct. Thank you and sorry for the confusion I’ve caused.

Only thing is, all users including guests can see the toggle on header. But as an admin when I am logged-in, I cannot see the toggles. Is this intentional? Could this be server cache or something?

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [February 17, 2022, 2:52pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/28 "2022-02-17T14:52:09Z")

</div>

Hmm that’s interesting. Do you have a dark and light color scheme selected in your user preferences?

And are you using the theme that has the component installed?

---

<div class="post-metadata">

### Author: ![Arta\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arta_s/32/537495_2.png) [@Arta\_S](https://meta.discourse.org/u/Arta_S)
#### Post date: [February 21, 2022, 9:40am UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/29 "2022-02-21T09:40:27Z")

</div>

I had to go to my profile and enable this option (Enable automatic dark mode color scheme) so it can appear on header. probably I was fidgeting around and missed that checkbox.

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/9/39330631ccdb285e56f80918131ca0529c3cba90.png)

---

<div class="post-metadata">

### Author: ![agungor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/agungor/32/260344_2.png) [@agungor](https://meta.discourse.org/u/agungor)
#### Post date: [May 13, 2022, 5:06pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/30 "2022-05-13T17:06:46Z")

</div>

I love this component! 😍 But, I am having a little issue.

It looks like the component only works when the “Enable automatic dark mode color scheme” option is enabled. My issue occurs when the option is enabled, and when the system preference is set to dark mode (i.e., preferred color scheme: dark).

In the scenario above, when I try to switch to a light theme vie Preferences \> Interface \> Theme, nothing happens, which is fine with me. Presumably, since my system preference is already set to dark mode, switching to light mode in Discourse does not override it.

When I do the same with the Dark / Light Mode Toggle component, and if my theme preference in Discourse is set to Light, the toggle actually lets me switch to light mode (which is even better in my view) but the site logo on the header remains in dark mode and hard to see in light mode. When I look in the inspector, I see the element looks like this:

`<div class="title"><a href="/" data-auto-route="true"><picture><source srcset="<link to image>" media="(prefers-color-scheme: dark)"><img src="<link to image>" id="site-logo" class="logo-big"></picture></a></div>`

I noticed the _media=“(prefers-color-scheme: dark)”_ part although we are now in light mode set by the toggle.

I should add that the site logo ordinarily switches fine between light and dark mode when the “Enable automatic dark mode color scheme” option in Discourse is unchecked. But, this prevents the Dark / Light Mode Toggle from being displayed 🤷🏻‍♂️

Also, if my theme preference in Discourse is set to Dark from Preferences \> Interface \> Theme, and my system preference is also dark, the toggle does not switch between light and dark—it always remains on the dark theme.

Ideally, I would prefer the Dark / Light Mode Toggle component to work the way it does now, but to make the site logo in the header follow the currently-active light/dark setting, not the user’s system preferred color scheme.

---

<div class="post-metadata">

### Author: ![MattiaB](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattiab/32/262975_2.png) [@MattiaB](https://meta.discourse.org/u/MattiaB)
#### Post date: [June 7, 2022, 5:55pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/31 "2022-06-07T17:55:42Z")

</div>

> [@agungor](#):
>
> When I do the same with the Dark / Light Mode Toggle component, and if my theme preference in Discourse is set to Light, the toggle actually lets me switch to light mode (which is even better in my view) but the site logo on the header remains in dark mode and hard to see in light mode.

Same here! Did you find a solution?

I’m no frontend developer but I did some debugging:  
When in dark mode, like my computer is set to, the HTML for the logo looks like this:

![image](https://global.discourse-cdn.com/meta/original/4X/3/8/d/38d41afe295f36c0a13643e2c989e8cd82656053.png)

And the logo looks fine, with dark mode fully working. When toggling to light mode, the theme goes light but the logo disappears (dark logo remains).

This is what the HTML looks like:

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/5/f/25f8663658d3069218fdaa04ce73a4ee1ef398fd.png)

There is an additional line, `<source srcset="https://radixtalk.com/uploads/default/original/1X/19838ecb731d3f87d9db76c927e793ab2e159f1e.png" media="(prefers-color-scheme: dark)">` which “blocks” the correct logo from loading. If I remove that line with Inspect Element, and only leave `<img src="https://radixtalk.com/uploads/default/original/1X/237090c67d33a1a38f9f031336dab420c4c4a37d.png" alt="RadixTalk" id="site-logo" class="logo-small" width="36">`, the correct logo shows up.

I hope this info was useful.

---

<div class="post-metadata">

### Author: ![agungor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/agungor/32/260344_2.png) [@agungor](https://meta.discourse.org/u/agungor)
#### Post date: [June 7, 2022, 9:18pm UTC](https://meta.discourse.org/t/dark-light-mode-toggle/215585/32 "2022-06-07T21:18:17Z")

</div>

> [@MattiaB](#):
>
> Same here! Did you find a solution?

I’m afraid not. I ended up changing the header background color in a way that switching the logo between light and dark mode no longer mattered 🤷🏻‍♂️

[Next page](https://meta.discourse.org/t/dark-light-mode-toggle/215585.md?page=2)
