Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to target component styles from host component angular 2

Tags:

angular

I have this :

@Component({
    selector: 'host-element',
    template: `<elementA></elementA>`,
    styles:[''] //styles here
})

export class hostElement {}

How do I target the styles of elementA component from host-element?

Thanks in advance!!

like image 582
Emmanuel Villegas Avatar asked Dec 14 '22 02:12

Emmanuel Villegas


2 Answers

:host elementA {
  // style here
}
like image 112
Günter Zöchbauer Avatar answered Jan 08 '23 22:01

Günter Zöchbauer


Angular has a special css operator /deep/, you can read about it here.

To make a style go beyond your component, put in your css (sass, less):

/deep/ .elemet-a-class {
   ... your style;
}

Or if you want to put it locally, just

styles: ['/deep/ .element-a-class { ... }']
like image 45
Meir Avatar answered Jan 08 '23 22:01

Meir