New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
Copy-pasted markup again, and a CSS tweak on the page next door breaks it without anyone touching my code.
What you'll have at the end
A custom element whose shadow root keeps its markup and styles unaffected by the surrounding page
You need
A UI block whose markup and CSS you've pasted onto more than one page, and a basic grip on JavaScript classes. No build step or bundler required.
Not covered
Letting the surrounding page set this block's own brand colors, or opening one internal element up for the parent to reshape directly. This only builds the sealed box; theming and restyling it from outside are separate jobs.
Let outside CSS theme a shadow-DOM component through custom properties
for letting the page hand this block its own brand colors and spacing from outside, once the sealed box itself is done
Expose one internal shadow-DOM element for the parent to restyle with ::part
for opening up one internal element, like the avatar's border, for the parent page to reshape directly
Checked 25 Aug 2026
Part of the Web Components cookbook