When I asked Google AI it responded:
Why combining them is wrong
The selector :host::part() attempts to mix these two concepts incorrectly:
- It tries to select an element with part="base". This can only be done from the component's consumer.
- However, it's chained to :host, which can only be used by the component author from inside the Shadow DOM.
Since ::part() is only visible to the host's parent DOM, and :host is only visible from within its own Shadow DOM, the two selectors operate in entirely separate scopes and can't be combined. It's like a house trying to paint its own outside wall from the neighbor's yard.
But then I saw this pattern all over Microsoft's homepage microsoft.com and wondered if there's ever a good reason to use it. Here's an example -
:host::part(tab-item__content) {
display: var(
--ds-tab-item-content-display,
${t(e.contentDisplay)}
);
flex-direction: var(
--ds-tab-item-content-flex-direction,
${t(e.contentFlexDirection)}
);
gap: var(--ds-tab-item-content-gap, ${t(e.contentGap)});
align-items: var(
--ds-tab-item-content-align-items,
${t(e.contentAlignItems)}
);
width: var(--ds-tab-item-content-width, ${t(e.contentWidth)});
max-width: var(
--ds-tab-item-content-max-width,
${t(e.contentMaxWidth)}
);
font-size: var(
--ds-tab-item-content-font-size,
${t(e.contentFontSize)}
);
font-weight: var(
--ds-tab-item-content-font-weight,
${t(e.contentFontWeight)}
);
...
}


