Skip to content

Feature request: CSS Element selectors local scope (encapsulation) #120

Open
@nabilnaffar

Description

@nabilnaffar

Feature request: Support CSS elements selectors local scope

We're developing components library and we're looking for a way to locally scope CSS element selectors styles.
for example:

:local(button){
   color: tomato;
} 

I want this style to affect only 1 component and not the whole buttons on the page of whoever uses it.

(the :local selector doesn't affect the button style encapsulation. )

Is there already a library/plugin that does that?

If not - a possible solution would be to add hashed custom attribute as Angular does:
https://blog.thoughtram.io/angular/2015/06/29/shadow-dom-strategies-in-angular2.html - ViewEncapsulation.Emulated

TL;TR:

<button custom-generated-attribute >Press here</button>
button [custom-generated-attribute]{
   color: tomato;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions