ShadowDom encapsulation attaches a genuine Shadow DOM root to the host element, giving true style isolation enforced by the browser rather than Angular's default attribute-based faking with _ngcontent selectors. This matters when the component is embedded into a host page with unknown, potentially conflicting global CSS, since Shadow DOM boundaries block outside styles from leaking in and vice versa. The tradeoff is that global styles like Bootstrap resets no longer apply inside, and CSS custom properties like --badge-color still pierce the boundary intentionally, making them the sanctioned channel for external theming.
import { Component, ViewEncapsulation } from '@angular/core';@Component({selector: 'app-widget-embed',standalone: true,encapsulation: ViewEncapsulation.ShadowDom,styles: [`:host {display: block;contain: content;}.badge {font-family: system-ui;color: var(--badge-color, #333);}`],template: `<span class="badge"><ng-content></ng-content></span>`,})export class WidgetEmbedComponent {}