discuss icon indicating copy to clipboard operation
discuss copied to clipboard

@apply not working in imported css with `a {}` only

Open Braincoke opened this issue 4 years ago • 2 comments

I am a beginner in CSS so this might be obvious to some of you. I tried to look at similar issues but I fail to see how they could be related.

I created the most simple gridsome project using TailwindCSS.

The project

My main.css looks like this:

@tailwind base;
@tailwind components;

@import "./theme-pink.css";

@tailwind utilities;

The theme-pink.css looks like this:

// This one is correctly applied
div {
    @apply bg-pink-200;
}

// This one is not
a {
    @apply text-red-600;
}

// This one is correctly applied
a:hover {
    @apply text-blue-500;
}

The issue

Every css in theme-pink.css is applied but the one with a { @apply text-red-600; }.

If move the problematic line in main.css then our style is applied:

@tailwind base;
@tailwind components;

@import "./theme-pink.css";

@tailwind utilities;

a {
    @apply text-red-600;
}

Try it yourself

If you feel like helping you can test this with this reproduction code : https://github.com/Braincoke/issue-tailwind-apply.

Would anyone know why this is not working ?

Braincoke avatar Mar 05 '20 09:03 Braincoke

Try this:

// all the tailwind stuff
@tailwind base;
@tailwind components;
@tailwind utilities;

// your custom styles
@import "./theme-pink.css";

cytRasch avatar Mar 05 '20 10:03 cytRasch

Oh yeah I had already tried this but unfortunately it didn't work :(

Braincoke avatar Mar 05 '20 10:03 Braincoke