Skip to content

Instantly share code, notes, and snippets.

@xdesro
Created May 28, 2020 16:33
Show Gist options
  • Save xdesro/597c34fd997629a598a3430463ffd8c7 to your computer and use it in GitHub Desktop.
Save xdesro/597c34fd997629a598a3430463ffd8c7 to your computer and use it in GitHub Desktop.
Caching specificity context using Sass' &.
.nav-item {
&__link {
color: red;
}
$this: &;
&:first-of-type {
&__link {
// this won't work 😞
color: blue;
}
#{$this}__link {
// this will, though! 💫
color: blue;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment