Skip to content

Instantly share code, notes, and snippets.

@kvlsrg
Last active October 21, 2017 20:06
Show Gist options
  • Save kvlsrg/4032a61c7a5496ec48b090e609931b62 to your computer and use it in GitHub Desktop.
Save kvlsrg/4032a61c7a5496ec48b090e609931b62 to your computer and use it in GitHub Desktop.
Sass @at-root Example

SCSS

.custom-select {
  // ...

  &--active {
    // ...
  }

  &--dark {
    // ...

    .custom-select__option {
      // ...

      &--value {
        // ...

        &::after {
          // ...

          // If block has both modifiers
          @at-root {
            .custom-select--active#{&} {
              // ...
            }
          }
        }
      }
    }
  }

  &__option {
    // ...

    &--value {
      // ...
    }
  }
}

Output CSS

.custom-select--dark .custom-select-option--value::after {
  // ...
}

.custom-select--active.custom-select--dark .custom-select-option--value::after {
  // ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment