liveBook · Manning

Shadow part

As explained in Web Components in Action

A shadow part is a named element in a shadow tree that can be styled from outside the shadow boundary through the CSS ::part mechanism.

A shadow part is a named element in a shadow tree that exposes a controlled styling hook through CSS ::part. It addresses a practical limitation of Shadow DOM: ordinary styles cannot cross the shadow boundary, which can otherwise prevent an application-wide design system from styling component internals. section 15.1

Shadow parts connect component encapsulation with modular design-system workflows. They let reusable components retain internal structure while making selected styling surfaces available to applications, frameworks, and themes. Their value is especially apparent when CSS is maintained as small, modular source files rather than one application-wide stylesheet. section 15.1

How Web Components in Action covers it

How deep it goes
Defines the styling role and motivation, but stops short of demonstrating markup, selectors, or browser compatibility details.
Examples
Uses design systems styling components and modular CSS source files as the main practical examples.
What it assumes
Assumes familiarity with Shadow DOM, CSS workflows, components, and design systems.
What you can do after
Evaluate how shadow parts can preserve component encapsulation while exposing styling surfaces to design systems.
How it connects
Connects Shadow DOM, CSS modules, design systems, application theming, Web Components, and framework-agnostic components.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Components in Action. The section links point to the parts of the book it draws on.