In Angular 17, I have a div with the class wrapper-my
.wrapper-my {
display: flex;
flex-direction: column;
align-items: flex-start;
align-self: stretch
width: 100%
}
.my-class {
width: inherit;
}
// parent component
<div class="wrapper-my">
<input type="text" class="my-class">
<app-input-my></app-input-my>
</div>
And in app-input-my
I have an input.
.my-class2 {
width: inherit
}
<input type="text" class="my-class2">
The input that is not in a component fills the entire space.
However, the input that is in app-input-my
does not fill the entire space
Even after doing this, it still doesn’t work.
<app-input-my class="my-class"></app-input-my>
How do I make my component work correctly according to the parent tag?
2
Answers
What can work is
::ng-deep
docs
It is "deprecated" for years.
from the docs:
Angular shims the css classes to emulate view encapsulation (a bit like with ShadowDom).
For your parent style to work on your child component you have to either :
ViewEncapsulation.None
on the parent.