In the midst of developing a custom form component for my Angular project, I am facing challenges with styling.
I wish to allow variable widths for the input element and have them controlled by the host component.
For instance: <my-input class="input">
should correspond to this class:
.input {
width: 250px;
}
However, when I attempt this approach, the styles are not being applied to my component.
I have noticed that some developers wrap their components in unnecessary divs and style those parent elements to fit the content inside. I prefer not to add wrappers solely for styling purposes but rather use CSS rules instead.
Is it necessary to utilize :host
?
Additionally, what about utilizing host-context(.input)
and then applying classes within the consumer's CSS
?