0

What should I write into scss file to set font-weight: bold; for the innner content of the component (so that the inner tags inherit it)? using

:host {
  font-weight: bold;
}

does this work but it makes it for the component tag itself as well.

What's the best technique in this case? Also, I would avoid to stick with using div, p, span or whatever tag is a child of the component tag.

Thank you.

Haradzieniec
  • 9,086
  • 31
  • 117
  • 212

2 Answers2

0

You can use the universal selector. Inside your component .scss place:

* {
  font-weight: bold;
}

The angular compiler will add the content host tag to the selector, which will result in something like *[_ngcontent-uch-c0].

Using the wildcard could have some performance impact though, so use carefully

Poul Kruijt
  • 69,713
  • 12
  • 145
  • 149
0

You can turn off encapsulation of the component

@Component({
  ...
  encapsulation: ViewEncapsulation.None
})

Take care if you do this then all global style could apply on the DOM inside of your component.

Bálint Réthy
  • 411
  • 1
  • 6
  • 25