1

I wonder what is a good practice of styling elements inside of child components from parent component level. I generally do it in 2 different aproaches:

1.Using /deep/ Plunker

Benefits:

  1. Less code
  2. We use only css to style elements

Disadvantages:

  1. We cannot use properties from typescript like in a 2nd approach
  2. We break component hermetization

2.Using input in child component Plunker

Benefits:

  1. We can use properties from typescript
  2. We don't break component hermetization

Disadvantages:

  1. More code and complicated - the deeper child, the more passes
  2. We sometimes don't need logic - but we are forced to write in .ts instead of using pure css mechanism

As you can see I have found pros and cons for both ways. I feel like answer might be "It depends" or maybe I miss another approach.

Community
  • 1
  • 1
Michał Lis
  • 461
  • 1
  • 6
  • 19
  • Possible duplicate of [Style child components from parent component's CSS file](https://stackoverflow.com/questions/36527605/style-child-components-from-parent-components-css-file) – Chrillewoodz Oct 02 '18 at 10:06

0 Answers0