Answer the question
In order to leave comments, you need to log in
How to change the theme of the admin panel using SASS / SCSS?
Goodnight.
I had the idea to implement a day / night theme change using SASS / SCSS. It turned out not so easy and not at all subject!
So far, I managed to find and
change this thing
- https://codepen.io/pawlek/pen/djyERV
$color-light: #fff;
$color-dark: #404549;
$('a.light').click(function(e){
e.preventDefault();
$(this).toggleClass('light dark');
if($(this).hasClass('light')){
$(this).html('<i class="fas fa-moon"></i>');
}
else{
$(this).html('<i class="fas fa-sun"></i>');
}
});
Answer the question
In order to leave comments, you need to log in
You collect from your sources (it doesn't matter, scss/sass/less/css/...) two CSS files - one with light theme styles, the other with dark theme. By clicking on the button through js, you change the link to the attached css file.
using SASS/SCSS.
If someone needs an adequate answer to the question, then the link is an article describing how easy it is to make a theme change based on a variable with themes, a mixin and a SCSS function through changing the class of the root element.
Example:
<div id="app" class="theme-light">
<div class="container">
<button class="button">Button</button>
</div>
</div>
.theme-light
, the root element will have the button in a light theme, and if you change the class to .theme-dark
, the button will change to a dark one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question