We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Switching themes programmatically in Vue Grid

I am trying to switch from the fabric theme to fabric-dark theme when switching from light mode to dark mode. I am setting up the application with v-app from vuetify. I wondering if its possible to switch between themes. Code Example of the template section below

MainApp.Vue
<template>
<v-app :dark="getDarkMode">
<v-content>
<v-container fluid>
<v-layout>
<ejs-grid
:dataSource="data">
     <e-column field="userId" width="120"></e-column>
<e-column field="username" headerText="Username" textAlign="Center" width="120"></e-column>
    </ejs-grid>       
</v-layout>
</v-container>
</v-content>
</v-app>
</template>



 

1 Reply

PS Pavithra Subramaniyam Syncfusion Team June 20, 2019 09:59 AM UTC

Hi Eric, 
 
Thanks for contacting Syncfusion support. 
 
From your query, we found that you want to change the Syncfusion components theme programmatically. So, we suggest to use the Syncfusion CDN styles to achieve this requirement. While using CDN you can achieve this like as below code snippet, 
 
CDN Links: 
 
<link class="syncTheme" rel='nofollow' href="http://cdn.syncfusion.com/ej2/ej2-base/styles/fabric.css" rel="stylesheet" /> 
<link class="syncTheme" rel='nofollow' href="http://cdn.syncfusion.com/ej2/ej2-vue-buttons/styles/fabric.css" rel="stylesheet" /> 
<link class="syncTheme" rel='nofollow' href="http://cdn.syncfusion.com/ej2/ej2-vue-grids/styles/fabric.css" rel="stylesheet" /> 
<link class="syncTheme" rel='nofollow' href="http://cdn.syncfusion.com/ej2/ej2-vue-popups/styles/fabric.css" rel="stylesheet" /> 
<link class="syncTheme" rel='nofollow' href="http://cdn.syncfusion.com/ej2/ej2-vue-navigations/styles/fabric.css" rel="stylesheet" /> 
<link class="syncTheme" rel='nofollow' href="http://cdn.syncfusion.com/ej2/ej2-vue-dropdowns/styles/fabric.css" rel="stylesheet" /> 
 
Button Click: 
 
onClick: function(args) { 
        var cssLink = document.getElementsByClassName('syncTheme'); 
        for (var i = 0; i < cssLink.length; i++) { 
            cssLink[i].rel='nofollow' href = cssLink[i].rel='nofollow' href.replace("fabric", "fabric-dark"); 
        } 
    } 
 
In this code we have used button click to change the fabric to fabric-dark theme. We have prepared the sample with this requirement and you can find that sample from the below link, 
 
 
Regards, 
Pavithra S. 


Loader.
Up arrow icon