Scoped Styling
Confining a set of style decisions to a subtree so the same component can look different in different contexts.
Scoped styling confines a set of design decisions to a region of the document — typically by declaring CSS Custom Property values under an attribute selector, so any element inside that region resolves tokens differently from elements outside it.
It is what makes one component library serve two visual languages at once: an editing interface with its own chrome tokens rendered around content styled by a tenant's own tokens, or a dark toolbar floating over a light page.
The rules that make it work are unforgiving. A utility that references a scoped token must itself be inside the scope. Putting the scope marker on an inner element while the outer element carries the tokenized utilities produces an outer element whose radius, shadow, and color resolve to nothing — and it fails silently, in ways a pixel comparison hides in the antialiasing. Portalled content leaves the scope, so an overlay rendered at the document body must re-declare the marker itself. And the theme mapping must substitute at point of use, or the token resolves at the root where the scope does not exist.
The corresponding test discipline is to assert computed values — the actual resolved radius and color — not merely that a class is present. A class that resolves to nothing is present.
See also7
CSS Custom Property
A user-defined CSS property that participates in the cascade and inherits down the tree.
Design & Interface10 connections
Design Token
Named design decisions — color, spacing, radius, type — stored as data so they can be shared and re-themed.
Design & Interface17 connections
Portal
Rendering an element into a different part of the document than its logical parent.
Web Platform15 connections
Dark Mode
Serving an alternate palette for low-light preference, and the three states that implies.
Design & Interface13 connections
Silent Failure
A failure that produces no signal, so the absence of an error reads as success.
Method63 connections
Utility-First CSS
Composing styles from many small single-purpose classes rather than authoring semantic rules.
Design & Interface11 connections
Cascade
The algorithm deciding which declaration wins when several apply to the same element.
Design & Interface9 connections
Related2
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from8
- CascadeDesign & Interface
The algorithm deciding which declaration wins when several apply to the same element.
- CSS Custom PropertyDesign & Interface
A user-defined CSS property that participates in the cascade and inherits down the tree.
- Dark ModeDesign & Interface
Serving an alternate palette for low-light preference, and the three states that implies.
- Design TokenDesign & Interface
Named design decisions — color, spacing, radius, type — stored as data so they can be shared and re-themed.
- OKLCHDesign & Interface
A perceptually uniform color space that makes lightness and chroma behave predictably.
- PortalWeb Platform
Rendering an element into a different part of the document than its logical parent.
- Shadow DOMWeb Platform
An encapsulated DOM subtree whose styles and structure are isolated from the rest of the page.
- Utility-First CSSDesign & Interface
Composing styles from many small single-purpose classes rather than authoring semantic rules.