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

Motivation for global styles

All the components require one or more css files to be added globally. This looks unusual to me. Shouldn't such style just be declared in the components requiring them? Shouldn't the styles used by the button simply be declated in buton.component.ts? What is the advantage of this?

1 Reply

JA Jesus Arockia Sankaran S Syncfusion Team May 21, 2019 05:11 PM UTC

Hi Stephan, 
 
Query 1: All the components require one or more css files to be added globally. This looks unusual to me. 
 
We maintain style sheet for each components separately, so we need to include the styles of dependent component also. But, we could use the style sheet of ej2 package which contains the styles of all components in single file to eliminate the multiple file reference. 
 
 Install EJ2 package in your application using below command. 
 
npm i @syncfusion/ej2 
 
Then add the style reference in your application. Please find the below link. 
 
@import ‘../node_modules/ej2/material.css’ 
 
Query 2: Shouldn't such style just be declared in the components requiring them? Shouldn't the styles used by the button simply be declated in buton.component.ts? What is the advantage of this? 
 
Bundle size will be large if we include the style reference in .ts file since style also will be included in the generated bundled file. So, we didn’t include the css files inside .ts files. 
 
Please get back to us if you required any further assistance on this. 
 
Regards, 
Jesus Arockia Sankaran S 
 


Loader.
Live Chat Icon For mobile
Up arrow icon