Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of ::ng-deep recommendation in angular

Tags:

sass

angular

Is using ::ng-deep in angular component scss right way of applying styling to third party components like datepicker, multiselect?

like image 752
Idris Rampurawala Avatar asked Jan 29 '19 11:01

Idris Rampurawala


People also ask

What is the use of :: ng-deep?

The ::ng-deep pseudo-class selector So this style will be applied to all h2 elements inside app-root , but not outside of it as expected. This combination of selectors is useful for example for applying styles to elements that were passed to the template using ng-content , have a look at this post for more details.

What is :: deep in CSS?

css file. The ::deep pseudo-element selects elements that are descendants of an element's generated scope identifier. The following example shows a parent component called Parent with a child component called Child .

Is NG :: deep deprecated?

The documentation at https://angular.io/guide/component-styles states this about :ng-deep : The shadow-piercing descendant combinator is deprecated and support is being removed from major browsers and tools.

Is ng-deep good practice?

Just don't use NG-Deep; it kind-of sort-of works but all the red flags are out on it and forget going too deep. Just use root level specific SCSS selectors as shown here! Here's another example of avoiding :ng-deep!


1 Answers

It's recommended to avoid using ng-deep as it is marked deprecated.

See here in the angular documentation

There has been raised a question what's the alternative here on stackoverflow

like image 52
Bernhard Avatar answered Sep 25 '22 20:09

Bernhard