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

Explore implementing @apply in terms of postcss-extend-rule #1044

Closed
adamwathan opened this issue Jul 22, 2019 · 5 comments
Closed

Explore implementing @apply in terms of postcss-extend-rule #1044

adamwathan opened this issue Jul 22, 2019 · 5 comments

Comments

@adamwathan
Copy link
Member

If I had known about this plugin when I created Tailwind, we probably wouldn't even have @apply and I would just be telling people to use this instead because it handles all of the annoying crap that @apply doesn't handle yet beautifully, like applying hover:bg-red-500 and stuff.

There are probably some special things we'd need to do to get the shadow lookup stuff working but in general I wonder if I should explore reimplementing apply using this plugin under the hood. Opening this issue so I don't forget :)

@TheDutchCoder
Copy link

Would it be possible to make this a priority?

Currently it's pretty much limiting any sort of inheritance in Tailwind and pretty much renders responsive classes unusable :(

// Fine
.input {
  @apply text-red;
}

.btn {
  @apply input;
}
// Already doesn't work :(
.input {
  @apply text-red;
}

@screen sm {
  .input {
    @apply text-blue;
  }
}

.btn {
  @apply input;
}

@camppacifictech
Copy link

Hi, on this topic, I just made a postcss plugin to 'preprocess' @apply at-rules so that variants can be used - basically it just expands any variant-prefixed classes in @apply rules to an @apply rule of the unprefixed class/es nested in the appropriate selector.

e.g. @apply hover:text-red => &:hover { @apply text-red; }

It handles all the provided Tailwind variants and has an option to specify additional custom variants and the selector that should be applied.

Hope someone finds it useful! It's my first PostCSS plugin so please feel free to provide any suggestions/enhancements!

@minimit
Copy link

minimit commented Aug 18, 2020

Watch out right now postcss-extend-rule has some problems to be resolved:
csstools/postcss-extend-rule#12
csstools/postcss-extend-rule#6
csstools/postcss-extend-rule#10

@DCzajkowski
Copy link

FYI @.adamwathan is working on this already: https://twitter.com/adamwathan/status/1293575524254732289

@DCzajkowski
Copy link

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

5 participants