I have a function, click a button to toggle the dark and light theme, I follow the below link:
https://ej2.syncfusion.com/themestudio/?theme=material
.light {
@import 'ej2/material.scss';
}
.dark {
@import 'ej2/material-dark.scss';
}
|
<div class="light">
<h1> Light Theme </h1>
<ejs-calendar class="light"></ejs-calendar>
<ejs-grid class="light" [dataSource]='data' [allowSorting]="true"
[allowFiltering]="true" [allowGrouping]="true">
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=120></e-column>
<e-column field='Freight' headerText='Freight' textAlign='Right' format='C2' width=90></e-column>
<e-column field='OrderDate' headerText='Order Date' textAlign='Right' format='yMd' width=120></e-column>
</e-columns>
</ejs-grid>
</div>
<br>
<div class="dark">
<h1> Dark Theme </h1>
<ejs-calendar class="dark"></ejs-calendar>
<ejs-grid class="dark" [dataSource]='data' [allowSorting]="true"
[allowFiltering]="true" [allowGrouping]="true" >
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=120></e-column>
<e-column field='Freight' headerText='Freight' textAlign='Right' format='C2' width=90></e-column>
<e-column field='OrderDate' headerText='Order Date' textAlign='Right' format='yMd' width=120></e-column>
</e-columns>
</ejs-grid>
</div>
|
From a quick glance at your code, I would say you need to set your CSS rule like this: body.light {...}Without the space between the tag and the class name.Assuming, you set the class on the body like this: <body class="light">
@import
makes all variables, mixins, and functions globally accessible."Hi lorryl,
Thank you for contacting Syncfusion support and sorry for the inconvenience.
We have checked your query and we want to inform you that we can change the dynamically using the generated file from theme studio as in the below KB (Knowledge Base) documentation. Also, we have shipped the dark theme with in package itself.
We have created a sample for dynamically changing the color that you can download from the below link.
Code Snippet:
./src/app/styles.scss
.light {@import 'ej2/material.scss';}.dark {@import 'ej2/material-dark.scss';}
./src/app/app.component.ts
<div class="light"><h1> Light Theme </h1><ejs-calendar class="light"></ejs-calendar><ejs-grid class="light" [dataSource]='data' [allowSorting]="true"[allowFiltering]="true" [allowGrouping]="true"><e-columns><e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column><e-column field='CustomerID' headerText='Customer ID' width=120></e-column><e-column field='Freight' headerText='Freight' textAlign='Right' format='C2' width=90></e-column><e-column field='OrderDate' headerText='Order Date' textAlign='Right' format='yMd' width=120></e-column></e-columns></ejs-grid></div><br><div class="dark"><h1> Dark Theme </h1><ejs-calendar class="dark"></ejs-calendar><ejs-grid class="dark" [dataSource]='data' [allowSorting]="true"[allowFiltering]="true" [allowGrouping]="true" ><e-columns><e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column><e-column field='CustomerID' headerText='Customer ID' width=120></e-column><e-column field='Freight' headerText='Freight' textAlign='Right' format='C2' width=90></e-column><e-column field='OrderDate' headerText='Order Date' textAlign='Right' format='yMd' width=120></e-column></e-columns></ejs-grid></div>
Please get back to us if you need any further assistance on this.
Regards,Jesus Arockia Sankaran S