Skip to content

[css-mixins] Are mixins inside a nested structure aware of its parents? #12016

@felix-bohlin

Description

@felix-bohlin

Hi ya'll, somewhat confusing title - let me explain! 😄

Let's say I have this code:

button {
   /* 
    .....
   */

   /* Cool effect */
    background-color: steelblue;

    &:where(:not([disabled])) {
      &:where(:not(:active):hover) {
         background-color: tomato;
      }

      &:where(:hover:active) {
        background-color: aquamarine;
      }
    }
  }
}

In this case it could be neat and cool if I could mixin this out like this:

@mixin --cool-effect {
  background-color: steelblue;
  
      &:where(:not([disabled])) {
        &:where(:not(:active):hover) {
           background-color: tomato;
        }
  
        &:where(:hover:active) {
          background-color: aquamarine;
        }
      }
    }
}

and use it:

button {
  @apply --cool-effect;
}

Will this even possible?

Take care, have a nice day! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.css-mixins

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions