Skip to content

@apply doesn't work with sm:, md:, hover:, etc. #3645

Closed
@684efs3

Description

@684efs3

I am using the latest version of Nuxt and Tailwind 2.0.

When I use @apply with responsive classes like sm:pt-2 or md:pt-2 or even hover:text-gray-900, I get an error like: @apply cannot be used with .sm\:pt-2 because .sm\:pt-2 either cannot be found, or its actual definition includes a pseudo-selector like :hover, :active, etc. If you're sure that .sm\:pt-2 exists, make sure that 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 have to basically break out the responsive breakpoints and the hover.

I feel like I used to be able to use
.link {@apply text-gray-800 hover:text-gray-900}. Now, I have to have two classes:
.link {@apply text-gray-800} and .link:hover {@apply text-gray-900}

Is there any way to get around this? It's pretty annoying because I have to write more code and now the css classes for one item is in multiple areas.

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