Implement selective CSS Reset within elements for preflight scope
#1992
Replies: 2 comments 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.
-
|
hi! I'm currently trying to fix the styles that are being overwritten by the maybe I'm missing something.. I couldn't find if there's something like that in docs, but it looks like it would be a solution for #4427 / #8275 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
The problem is the
preflightconfiguration's inability to selectively apply resets to siblings within the same scope, limiting styling flexibility in complex web layouts.Problem Statement/Justification
Background
The
preflightconfiguration 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 requirespreflightscope.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, andimgall 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
buttonandimgtagged with.my-scope, but not toinput. This selective application is not feasible with the currentpreflightscope configuration.Proposed Solution or API
The proposed solution involves enhancing the
preflightconfiguration with additional options for more granular control over the scope of the CSS reset. The configuration would be as follows:Behavior Based on the
levelSettingParent Level Scope
levelis set to'parent', the CSS reset is applied to all child elements within the parent container having the specified scope class.Element Level Scope
levelto'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