Skip to content

Instantly share code, notes, and snippets.

@vielhuber
Last active October 4, 2022 21:36
Show Gist options
  • Save vielhuber/46d228dbb8360940f198d1dbee43be28 to your computer and use it in GitHub Desktop.
Save vielhuber/46d228dbb8360940f198d1dbee43be28 to your computer and use it in GitHub Desktop.
circular dependency tailwindcss #css

html

<div class="
    w-full
    h-96
    text-white
    bg-black
    after:relative
    after:-top-8
    after:content-['circular_dependency_test']
"
></div>

scss

.bg-black {
    &:after {
        @apply bg-black;
    }
}

error

You cannot @apply the bg-black utility here because it creates a circular dependency.

solution 1

[class~='bg-black'] {
    &:after {
        @apply bg-black;
    }
}

solution 2

<div class="
    bg-black
    after:bg-black
"
></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment