Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
684efs3 opened this issue Feb 24, 2021 · 2 comments
Closed

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

684efs3 opened this issue Feb 24, 2021 · 2 comments

Comments

@684efs3
Copy link

684efs3 commented Feb 24, 2021

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.

@684efs3
Copy link
Author

684efs3 commented Feb 24, 2021

Nevermind, looks like this solves it: #2159

Weird, I used an old version of Nuxt and Tailwind and did not need to use the experimental module, but with the next Nuxt and Tailwind 2.0, I do.

I love Tailwind. Hope this gets incorporated into the default settings!

@bradlc
Copy link
Contributor

bradlc commented Feb 26, 2021

Hey @684efs3, looks like you've got it working but for future reference: The @nuxtjs/tailwindcss module (which is used when selecting Tailwind CSS while creating a new Nuxt project) is using tailwindcss v1.9.6 which is why this doesn't work out-of-the-box.

We have a guide which explains how you can install the latest version within a Nuxt app 👍

@bradlc bradlc closed this as completed Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants