Change theme js

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!')
	}
});

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?).

2 Likes

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