Rename pin utilities to top/right/bottom/left/inset and make customizable #764
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.
In Tailwind 0.x we took the fairly heavy handed approach of assuming that anything you could accomplish with
top: {value}
could also be accomplished withtop: 0; margin-top: {value}
. We did this mostly for file size concerns, and take to advantage of Tailwind's inherit composability so it wasn't necessary to duplicate the spacing scale to yet another category of utilities.Because of that stance, we named the top/right/bottom/left classes
pin-{side}
, because the idea is that you were pinning the element to some edge of the container, since we only supported a zero value. This was also convenient because we wanted to be able to pin an element to all sides using a single class, and unlike margin/padding, CSS didn't have any sort of shorthand property for setting top/right/bottom/left all at once, so we had nowhere to draw naming inspiration from (or so we thought.) If we calledpin-t
top-0
instead, what would we callpin-x
?Later I discovered that there is at least one very important use case for setting a
top
value other than zero, and that's when working with sticky positioning, one of the most useful new-ish features I've ever come across in CSS.When I realized I needed stuff like
top-16
to get sticky positioned elements in the right place, I started to regret ourpin-t
approach. I also realized that people sometimes need things likeleft: 100%
when you are trying to position an element outside of its parent, like you might do with a complex nested dropdown.People have suggested supporting classes like
pin-t-16
orpin-l-full
in the past, but that feels like a bad name compared totop-16
orleft-full
, so instead of living with that naming debt forever I think it's worth fixing it now for 1.0.The question of course was what to name the shorthand
pin
,pin-x
, andpin-y
properties 🤔 Well it turns out, in the new-ish CSS Logical Properties and Values spec there is a newinset
property, which is a shorthand for top/right/bottom/left! 🎉So this PR introduces the following class name changes:
.pin-none
.inset-auto
.pin
.inset-0
.pin-y
.inset-y-0
.pin-x
.inset-x-0
.pin-t
.top-0
.pin-r
.right-0
.pin-b
.bottom-0
.pin-l
.left-0
It also adds the following new classes by default:
.inset-y-auto
.inset-x-auto
.top-auto
.right-auto
.bottom-auto
.left-auto
It also makes all of these values customizable using a new
inset
key in the theme config:These classes now live in a new
inset
plugin instead of theposition
plugin, so their variants are also controlled separately:This is an annoying BC break but I think it's worth it to not regret the
pin-{side}
naming convention for years to come.