Skip to content

@apply cannot be used with '.bg-*' #396

@jsardev

Description

@jsardev

First of all - thank you for Tailwind, it's freakin' amazing! :)

I'm playing around with it right now on my Nuxt.js stack and unfortunately I can't make this one thing work for me.

What I'm trying to do is to @apply .bg-grey; to body, like this:

@tailwind preflight;

body {
  @apply .bg-blue;
}

@tailwind utilities;

But the code above returns:

Module build failed: Syntax Error

(6:3) `@apply` cannot be used with `.bg-blue` because `.bg-blue` either cannot be found, or it's actual definition includes a pseudo-selector like :hover, :active, etc. If you're sure that `.bg-blue` exists, make sure t
hat any `@import` statements are being properly processed *before* Tailwind CSS sees your CSS, as `@apply` can only be used for classes in the same CSS tree.

I've tried also some other things, like @apply .test-blue; and it worked properly.

Any ideas? I may misunderstand something so any info would be much appreciated :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions