Say I have a native web component with an HTML template like so:
<wc-grid>
<slot></slot>
</wc-grid>
Now I have the following two use cases (one with a text input the other with a radio):
<wc-grid> <input type="text"> </wc-grid>
<wc-grid> <input type="radio"> </wc-grid>
Is it possible to style the <wc-grid>
differently depending on when whether it contains a text or radio type input?
e.g. If has()
was around it would be something like this: (trying to change whether the grid is vertical or horizontal depending on the widget inside of it):
:host:has(> input[type="text"]) { flex-direction: row; }
:host:has(> input[type="radio"]) { flex-direction: column; }
Research has lead me to learn about :has()
, but that has not landed yet.
And as far as I can tell :host-context
would not help either as it looks up, not down, besides its poor support.