Change special keyword 'default' to 'DEFAULT', make negative prefixes work across all plugins #2580
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 aims to simplify how utility class names are generated in Tailwind in order to make things much more consistent and predictable.
This is a breaking change and slated for v2.0.
Currently in Tailwind, several core plugins support a special
default
key in the config which tells Tailwind to generate a utility with no suffix:This is useful but confusing, because many other plugins don't support this, for example:
Similarly, many plugins support generating classes that are prefixed with
-
by adding-
to the beginning of the key name:...but others don't:
This is confusing and makes the codebase complicated. The problem is, for some plugins we really do need to be able to include "default" in the utility name, like
cursor-default
.So this PR replaces all usage of the lowercase
default
with the uppercaseDEFAULT
. The uppercaseDEFAULT
always means "with no suffix", and lowercase is just a regular string with no special meaning.This PR also makes things consistent so that
DEFAULT
can be used anywhere for any plugin, and so can the-
prefix. This lets you make really stupid classes like-font-sans
but that's your decision.I've also updated the use of "default" in variants. We allow you to control the position of the default variant by adding "default" to your variants list:
This has been replaced with
DEFAULT
as well, so that things are consistent.The last place this has been updated is when customizing the per-screen-size padding of the container:
Updating for this change isn't too painful (just replace
default
withDEFAULT
everywhere in your config where you want no suffix, and stuff liketheme('borderRadius.default')
withtheme('borderRadius.DEFAULT')
in your CSS) but is slightly annoying admittedly. I'm sorry.