I cannot seem to find a problem or I am misunderstanding something (I use daisyui + nx + tailwind css + angular). Very simplified scenarios for my problem:
- For first scenario I have:
<div class="flex flex-row">
<div class="btn btn-primary w-1/2"></div>
<app-home-side-bar></app-home-side-bar>
</div>
where side-bar component is:
<div class="btn btn-primary w-1/2"></div>
However,
- In this scenario I have everything in one place:
<div class="flex flex-row">
<div class="btn btn-primary w-1/2"></div>
<div class="btn btn-primary w-1/2"></div>
</div>
Why included component ignores the 50% width parameter?
2
Answers
you can make rendering behave like app-home-side-bar component tag doesn’t exist.
app-home-side-bar.scss
the result is the same as side-bar internal nodes were direct children of the tag where it was rendered
Using the attribute selector to initialize the component, so that no CSS changes will be needed!
In the below example, we have changed the
selector
property to check the attributeComponentSelector
instead of the html tags, this has the advantage that the component CSS is not messed up, since we initialize through the attributes!Usage on the parent
Alternative
Please add the CSS to the angular tag that contains the HTML, you need to add it to the
host
property of@component
decorator, this will ensure the CSS gets applied to the root component selector.