# Change theme js

**URL:** https://meta.discourse.org/t/change-theme-js/102251
**Category:** Support
**Created:** [November 17, 2018, 9:13pm UTC](https://meta.discourse.org/t/change-theme-js/102251 "2018-11-17T21:13:10Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![matotubol](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@matotubol](https://meta.discourse.org/u/matotubol)
#### Post date: [November 17, 2018, 9:13pm UTC](https://meta.discourse.org/t/change-theme-js/102251/1 "2018-11-17T21:13:10Z")

</div>

Is there a script so user can change Theme ligt/dark by clicking on it,  
im using the alien-night-discourse theme and they have the option to click on the sun or moon to change it but it doesnt change the theme only the background, here is the JS

```
<script async>
$(document).ready(function() {
	var darkTheme = localStorage.getItem("theme");
	if (darkTheme !== null){
		$('html').addClass('dark');
	}
	if (typeof(Storage) !== "undefined") {
		// Code for localStorage/sessionStorage.
		$('.theme-switcher-dark').on('click', function() {
			localStorage.setItem("theme", "dark");
			$('html').addClass('dark');
		});
		$('.theme-switcher-light').on('click', function() {
			localStorage.removeItem("theme");
			$('html').removeClass('dark');
		});
	} else {
		// Sorry! No Web Storage support..
		console.log('Upgrade to a better browser! Really!')
	}
});

```

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [November 17, 2018, 9:17pm UTC](https://meta.discourse.org/t/change-theme-js/102251/2 "2018-11-17T21:17:11Z")

</div>

Did you have no luck with the Theme guide here? You should consider posting there to grab the attention of those already on that Topic (and it’s better board etiquette in any case?).

> [@Alien Night Theme - A free Dark Theme for Discourse](https://meta.discourse.org/t/alien-night-theme-a-free-dark-theme-for-discourse/54175):
>
> discourse2Summary Discourse Alien Night is a dark focused clean theme with the Dark/Light toggle component in mind to enhance your forum!eyeglassesPreview [Preview on theme-creator.discourse.org](https://theme-creator.discourse.org/theme/B-iggy/alien-night-theme)hammer_and_wrenchRepository Link [GitHub - B-iggy/alien-night-discourse-dark-theme: A night friendly dark Discourse theme - dark/light switcher inclusive · GitHub](https://github.com/B-iggy/alien-night-discourse-dark-theme)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) Note: with the release 4.0.0 …

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [September 9, 2021, 3:48pm UTC](https://meta.discourse.org/t/change-theme-js/102251/3 "2021-09-09T15:48:01Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 12, 2021, 12:49am UTC](https://meta.discourse.org/t/change-theme-js/102251/4 "2021-10-12T00:49:34Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
