I am using <p-calendar>
in one of my components. I am trying to style it using a class in my sass-file, but inputStyleClass
does not have any effect at all. In fact, I can't even see the class in the styles of Chromes DevTools. It is however shown as an attribute of the <input>
element (ng-reflect-klass="calendar-input"
).
I have read all I could find (e.g. inputStyleClass PrimeNg Angular 2) and tried doing things accordingly.
These are reduced examples of the relevant files:
time-edit.component.html
<p-calendar [inputStyleClass]="'calendar-input'"></p-calendar>
time-edit.component.sass
.calendar-input
border-left: 5px solid #a94442 !important
time-edit.component.html
<p-calendar [inputStyle]="{'border-left': '5px solid #a94442'}"></p-calendar>
However, I do not want to style it this way.
What am I doing wrong? Why can't my class from the sass file be found?
This happens due to angular's ViewEncapsulation
which is set to ViewEncapsulation.Emulated
by default.
In order to style a child component style you have the following options:
ViewEncapsulation.None
::ng-deep
, note this is not recommended since it is mareked as deprecatedYou can see a working example with ViewEncapsulation.None
in this stackblitz