Hi Vasamsetti,
To ensure that your CSS styles are properly applied in an Angular component, you should follow these best practices:
- Angular Component Style Isolation: By default, styles defined in a component's CSS file are scoped to that component. If you want your styles to apply globally or affect third-party library elements, you need to override this behavior.
- Using ViewEncapsulation.None: You have checked ViewEncapsulation.None in your component decorator, which means that styles will not be scoped to this component and can apply globally.
- Ensure CSS Specificity: Make sure your CSS selectors are specific enough to target the elements created by the Syncfusion Schedule component.
- Loading CSS Files: You don't need to add styles to angular.json if you want them to be scoped to a component. However, for global styles, you should add them to styles in angular.json.
[app.component.css]
.schedule-cell-dimension.e-schedule .e-vertical-view .e-date-header-wrap table col, .schedule-cell-dimension.e-schedule .e-vertical-view .e-content-wrap table col { width: 200px; } |
[app.component.ts]
once ensure ViewEncapsulation.None is correctly used in your project.
import { Component, ViewEncapsulation } from '@angular/core'; import { MonthService, DayService, WeekService, WorkWeekService, TimelineViewsService, TimelineMonthService, ResizeService, DragAndDropService } from '@syncfusion/ej2-angular-schedule'; @Component({ selector: 'app-root', templateUrl: 'app.component.html', styleUrls: ['app.component.css'], encapsulation: ViewEncapsulation.None }) export class AppComponent { // Your component logic here } |
[angular.json]
"projects": { "demo": { "root": "", "sourceRoot": "", "projectType": "application", "prefix": "app", "schematics": {}, "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/demo", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.app.json", "assets": [ "favicon.ico", "assets" ], "styles": [ "src/styles.css", "src/app/app.component.css" ], "scripts": [] }, } |
Sample link: https://stackblitz.com/edit/angular-iucqkv-s1vpwf?file=angular.json,src%2Fapp.component.ts
Please get back to us if you need any further assistance
Regards,
Vijay