is angular ViewEncapsulation necessary?

85 Views Asked by At

I was a big fan of ViewEncapsulation in angular components. But I see if we set it to ViewEncapsulation.None - we can also encapsulate styles by just component selector in SCSS. For example:

my-component {
  h1 {}
  button {}
 etc..
}

Also If I want to use for example some material.angular component and customize it inside my-component it's easier and clean without Encapsulation:

When Encapsulation is on:

:host ::ng-deep (which is deprecated) {
  mat-expansion-panel {
    some-internals {}
  }
} 

When Encapsulation is off:

my-component {
  mat-expansion-panel {
    some-internals {}
  }
} 

What do you think about that? are there some arguments to use Encapsulation and not go by selector encapsulation pattern?

0

There are 0 best solutions below