Is there a way to seal my Angular component off from the global style sheet? I don't want the styles in the global style sheet to take effect inside my component.
I have tried this
.reset {
all: initial;
* {
all: unset;
}
}
but is there not a different way?
You can use the :not selector in your global CSS.
You need to Emulate the encapsulation property on your Component .
The important thing to remember is to place the GlobalStyle component as a sibling component to your main application component(s). And that's it! Global styling is now all set up with Styled Components.
In your component decorator, add:
@Component({
selector: '..',
templateUrl: '..',
styleUrls: ['..'],
encapsulation: ViewEncapsulation.ShadowDom
})
This will create a shadow dom and will force your component to use styles only from the provided styles/styleUrls array.
If you are using angular version < v6.1.0. You can use ViewEncapsulation.Native. It's deprecated after that.
try this, it must work:
:host ::ng-deep .reset{
//your style
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With