Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 how to style transcluded elements?

Tags:

angular

<component>
  <p class="component-p"></p>
</component>

component stylesheet:

.component-p {
  color: red;
}

:host .component-p {
  color: red;
}

:host >>> .component-p {
  color: red;
}

>>> .component-p {
  color: red;
}

::content .component-p {
  color: red;
}

None of these seem to work, but I don't understand why.

If I put ::content .component-p in the parent component of this then it works, but that doesn't make any sense since I'm not transcluding it into the parent, but rather the child which is component.

How do you style transcluded content?

like image 386
Chrillewoodz Avatar asked Sep 03 '26 20:09

Chrillewoodz


1 Answers

Use :host /deep/ .component-p when using angular-cli.

https://medium.com/google-developer-experts/angular-advanced-styling-guide-v4-f0765616e635

like image 87
David Domingo Avatar answered Sep 08 '26 11:09

David Domingo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!