I have a custom component which is using another component within it but slotted. The component is set up like this:
<div class="nys-modal">
<!-- rest of component -->
<div class="nys-modal_footer">
<slot name="actions"></slot>
</div>
</div>
and so the implementation is
<nys-modal>
<!-- other content not in slot -->
<div slot="actions">
<nys-button label="Action 1"></nys-button>
<nys-button label="Action 2"></nys-button>
</div>
</nys-modal>
I have a css variable --_nys-button-width set up which I can override in the nys-modal.styles file but it only works if the <nys-button> is set up in the <nys-modal>, not when it is passed in through the slot. I want to override the --_nys-button-width to be 100% but something like the following doesn't work:
::slotted([slot="actions"]) nys-button {
--_nys-button-width: 100%;
}
This is only an issue on the slot. I can easily manipulate --_nys-button-width (or any of my other css vars) for the nys-button in the nys-modal component that is not a slot with:
nys-button {
--_nys-button-width: 100%;
}
::slotted()selectors only apply to the slotted element itself, not its children.