Skip to content

CSS Modules does not support deep selector #1703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hoomersinpsom opened this issue Jul 28, 2020 · 7 comments
Open

CSS Modules does not support deep selector #1703

hoomersinpsom opened this issue Jul 28, 2020 · 7 comments

Comments

@hoomersinpsom
Copy link

What problem does this feature solve?

when using css modules, the deep selector '>>>' does not work at all, when using css scoped it works fine, would be great if css modules has this feature

What does the proposed API look like?

<style lang="postcss" module>
.container  >>> .children {
  color: red;
}
</style>
// should be parsed to

<style type="text/css">
.container_Xz11 .children{
  color: red
}
</style>
@posva posva transferred this issue from vuejs/vue Jul 28, 2020
@posva
Copy link
Member

posva commented Jul 28, 2020

@hoomersinpsom transfered to #1703

@ms-fadaei
Copy link

ms-fadaei commented Mar 6, 2021

@posva any update?

@rijenkii
Copy link

vuejs/core#7524

Because :deep() is specifically as feature of scoped css, not module. It does not translate to how CSS modules work.

This issue can be closed as "won't fix" I assume.

@rijenkii
Copy link

After a bit of research, it turns out that CSS Modules has its own analog of :deep -- :globlal!
https://github.com/css-modules/css-modules#exceptions

Example:

.parent > :global(.child) {}

Is compiled to:

._parent_pjgkn_1 > .child {}

@PerpetualWar
Copy link

If we are using css modules exclusively in a project, and this is not supported, how to update child component styles from parent?

@rijenkii
Copy link

rijenkii commented Aug 8, 2023

There is no way to target a class defined in a child's <style module>.
Consider adding a parameter to the child to control its style.

Alternatively, you can define some classes in a regular <style>, use them in your child component and then target them from parent with :global().

@joey-carlisle4
Copy link

After a bit of research, it turns out that CSS Modules has its own analog of :deep -- :globlal! https://github.com/css-modules/css-modules#exceptions

Example:

.parent > :global(.child) {}
Is compiled to:

._parent_pjgkn_1 > .child {}

link update https://github.com/css-modules/css-modules/blob/master/docs/composition.md#exceptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants