Hello All,
I have implemented a dynamic theme toggle similar to the primeng showcase page. However I could only figure out how to implement it using css files. Basically I just used some javascript to change the link of the css file from the index.html file, also similar to the showcase. Not sure if it's possible with binding or using angular specifically. Anywho I was curious if this same type of end result is possible using all .scss files instead of css, I would prefer to primarily use scss files but it seems because they are not static it will not let me change the links using this code.
Anyone implement dynamic theme changes using scss files at runtime?
Best
Dynamic Theming using Sass?
Note that I did try to set up my workspace exactly like the "showcase" app before posting this. In the code for the showcase page it has a link to as .css file in index.html:
In the method that changes theme it links another .css file..
However in that directory 'assets/components/themes/' + theme + ' there are .scss files? I'm not sure if I'm overlooking something? When I set up my code in this fashion and click on a theme I want to dynamic switch to, I receive this error in the console log:
"Resource interpreted as Stylesheet but transferred with MIME type text/plain:"
Thank you
Code: Select all
<link id="theme-css" rel="stylesheet" type="text/css" href="assets/components/themes/omega/theme.css">
Code: Select all
changeTheme(event: Event, theme: string) {
let themeLink: HTMLLinkElement = <HTMLLinkElement> document.getElementById('theme-css');
themeLink.href = 'assets/components/themes/' + theme + '/theme.css';
event.preventDefault();
}
"Resource interpreted as Stylesheet but transferred with MIME type text/plain:"
Thank you
-
- Posts: 25
- Joined: 31 Jan 2013, 02:54
As much as I hate "Me too" posts.... Me too.
I note that you received no responses from any of the developers or other users, so I was wondering if you figured this one out on your own. I want to swap between dark and light themes using the sass based option and I have almost decided it is impossible. If you have solved this can you share?
I note that you received no responses from any of the developers or other users, so I was wondering if you figured this one out on your own. I want to swap between dark and light themes using the sass based option and I have almost decided it is impossible. If you have solved this can you share?
PrimeNG (Angular): Apollo, Mirage
PrimeFaces (JSF)
PrimeFaces (JSF)
-
- Posts: 16
- Joined: 19 Jan 2021, 17:30
Including myself in this thread - if i find out, will post here as well.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 23 guests