Repository navigation
JIT: Add support for before/after pseudo-elements - #4461
Merged
Merged
Conversation
|
I might be wrong, but I can't extend module.exports = {
variants: {
extend: {
before: ['dark']
},
},
}Because I have the following error: variantsValue is not iterableI tried:
EDIT I think I have nailed down the issue, there is no need to extend, it seems to work, but the |
This was referenced Jun 17, 2021
13 tasks done
7 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for
::beforeand::afterpseudo-elements, as well as thecontentproperty to the JIT engine.Usage looks like this:
Any utility that is applied with a before/after variant automatically includes
content: ""by default to avoid having to add that yourself every single time, so the rules above are actually generated like this:This means
content: ""is going to be duplicated several times in your CSS if you use this feature, but I think it's worth it for the improved developer experience given how well that will ultimately compress.Out of the box,
content-noneis the only available preconfigured content utility. Those values can be of course extended in yourtailwind.config.jsfile though, under thecontentkey.The
contentutilities have complete arbitrary value support though, which is where I think they are most useful:They even support stuff like the
attrfunction, so you can reference a value stored in an attribute:I considered making this behavior the default with a fallback to an empty string if the attribute didn't exist, but ultimately decided against it since deciding on the name for the default attribute is tricky and introduces a lot of naming collision potential in people's real world projects.
As mentioned earlier, these features are JIT only.