V
V
Vitaly2017-10-27 13:39:46
Angular
Vitaly, 2017-10-27 13:39:46

How to change css of nested element in Angular?

There was a need to override the style of the inner component, but Angular isolates all styles from external attacks. How to solve this problem?
Example: menu.component uses ngx-bootstrap tabs, you need to set a background for them.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sasha Novik, 2017-10-28
@vitali1995

::ng-deep .tab-class {
  background: red
}

https://angular.io/guide/component-styles#deprecat...
But even with this feature, it is considered bad practice and generally declared deprecated (without a deprecated term from the api). The component itself must decide how it should look based on parameters, css variables, :host-context. It is clear that the third ones, if they do not provide for such a parameter, cannot be fixed in another way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question