|
app.js
function ChangeTheme(isDark) {
document.getElementsByTagName('body')[0].style.display = 'none';
let synclink = document.getElementById('theme');
let applink = document.getElementById('apptheme');
synclink.rel='nofollow' href = isDark ? 'css/fabric-dark.css' : 'css/fabric.css';
applink.rel='nofollow' href = isDark ? 'css/site-dark.css' : 'css/site.css';
setTimeout(function () { document.getElementsByTagName('body')[0].style.display = 'block'; }, 200);
} |
| app.js function ChangeTheme(isDark, theme) { if (theme == null) {
// We have set the default initial load theme as fabric in _host.cshtml
// <link rel='nofollow' href="_content/Syncfusion.Blazor/styles/fabric.css" rel="stylesheet" id="theme"/>
getTheme = isDark ? "fabric-dark": "fabric";
} else {
getTheme = isDark ? JSON.parse(theme).Text + '-dark' : JSON.parse(theme).Text;
}
let Theme = document.getElementById('theme');
Theme.rel='nofollow' href = '_content/Syncfusion.Blazor/styles/' + getTheme + '.css';
document.getElementsByTagName('body')[0].style.display = 'none';
let applink = document.getElementById('apptheme');
applink.rel='nofollow' href = isDark ? 'css/site-dark.css' : 'css/site.css';
setTimeout(function () { document.getElementsByTagName('body')[0].style.display = 'block'; }, 200);
}
function ThemeChange(theme, isDark) {
getTheme = isDark ? JSON.parse(theme).Text + '-dark' : JSON.parse(theme).Text;
//Here we change the theme for syncfusion components. You can change it to 'apptheme' insteadof using 'theme'.
let Theme = document.getElementById('theme');
Theme.rel='nofollow' href = '_content/Syncfusion.Blazor/styles/' + getTheme + '.css';
} |
Hi,
Your question isn't quite clear to me, I mean you are asking If you can switch from your existing theme to another theme?
If this the question then you can create a child theme of your parent theme, You can implement all the changes you want in your WordPress theme but you have to be careful when any update of that specific theme (Parent theme) comes because while updating your theme it can cause serious trouble to your website. So make sure before updating any theme. Although there are many best WordPress themes that can allow you to create a child theme for your website.
Hi Stefan,
Greetings from Syncfusion Support !
Based on the provided details, we understand that you want to persist the light/dark theme preference so that when a user revisits or reloads the site, their previously chosen theme is retained. This can be accomplished by saving the selected theme in the browser's local storage. We have developed a Blazor Web App targeting .NET 8.0, where we implemented a SfDropDownList for theme selection and a toggle button for switching between light and dark modes.
Please review the attached sample for your reference and let us know if our understanding of your requirements is incorrect.
Regards,
Subathra K