Implement selective CSS Reset within elements for preflight
scope
#1992
kris-ellery
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
I'm building a web extension that injects content into a page using shadow DOM and this functionality would be extremely handy. I can scope tokens to :host but it looks like I'll ultimately have to build my own resets that are properly scoped since the reset layer ends up polluting the global scope and causing issues with the page outside of the shadow DOM. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
The problem is the
preflight
configuration's inability to selectively apply resets to siblings within the same scope, limiting styling flexibility in complex web layouts.Problem Statement/Justification
Background
The
preflight
configuration option is designed to set the scope for CSS reset, useful for styling whole sections of a website. However, challenges arise in scenarios where sibling elements require different scopes - one needs a global scope while another requirespreflight
scope.Current Implementation and Its Limitation
In the existing setup, all child elements within a scoped division inherit the CSS reset. For example:
In the above structure,
button
,input
, andimg
all inherit the reset styles applied to.my-scope
.Issue Encountered
The current implementation does not support selective reset application on sibling elements within the same parent. For instance:
Here, the desired outcome is to apply the reset only to
button
andimg
tagged with.my-scope
, but not toinput
. This selective application is not feasible with the currentpreflight
scope configuration.Proposed Solution or API
The proposed solution involves enhancing the
preflight
configuration with additional options for more granular control over the scope of the CSS reset. The configuration would be as follows:Behavior Based on the
level
SettingParent Level Scope
level
is set to'parent'
, the CSS reset is applied to all child elements within the parent container having the specified scope class.Element Level Scope
level
to'element'
applies the reset directly to the individual elements that have the scope class assigned.This approach allows for more flexibility, enabling selective application of CSS resets either to an entire parent container or to specific elements within a container.
Alternatives
No response
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions