[Feature Proposal] CSS Logical Properties (margin-inline-start...) #1483
Replies: 27 comments 12 replies
-
You don't actually need that in Tailwind, this can be done using PostCSS plugins. |
Beta Was this translation helpful? Give feedback.
-
@ahmadalfy can you explain? |
Beta Was this translation helpful? Give feedback.
-
I would even go as far to say that maybe the default |
Beta Was this translation helpful? Give feedback.
-
Hi, check out this plugin: tailwindcss-rtl which is probably what you are looking for. |
Beta Was this translation helpful? Give feedback.
-
@20lives love your plugin, why don't you use |
Beta Was this translation helpful? Give feedback.
-
thank you @HapLifeMan |
Beta Was this translation helpful? Give feedback.
-
In that way, do you think it would be possible to add an option in your plugin to decide whether we want to work with parent direction or CSS logic? 😊 |
Beta Was this translation helpful? Give feedback.
-
I don't really mind changing it :) |
Beta Was this translation helpful? Give feedback.
-
Can I offer some help? |
Beta Was this translation helpful? Give feedback.
-
I would much prefer if I could use "start" and "end" instead of "right" and "left", it matches with flexbox's naming, and it doesn't assume a writing direction |
Beta Was this translation helpful? Give feedback.
-
tailwindcss-rtl should just be part of tailwind imo |
Beta Was this translation helpful? Give feedback.
-
@MathGeniusJodie I found tailwindcss-logical and it does the job very well! It's working very well without having to deal with |
Beta Was this translation helpful? Give feedback.
-
logical properties are supported in edge now, so no more technical reason why this can't be done |
Beta Was this translation helpful? Give feedback.
-
@HapLifeMan @MathGeniusJodie tailwindcss-rtl already implemented logical properties (with support for legacy browsers) |
Beta Was this translation helpful? Give feedback.
-
hi. please add CSS Logical Properties. its very useful for RTL. you can use that in "Space Between" and "Divide" that now have problems with RTL direction. and even add some new padding and margin class like pi -> padding-inline and more same classes for margin and border it's very useful and support by all new browsers |
Beta Was this translation helpful? Give feedback.
-
This is something we've looked into a bunch of times but ends up being a bit more complicated than it sounds. Not closed to it, definitely will explore it again at some point. Biggest naming challenge is is |
Beta Was this translation helpful? Give feedback.
-
It’s pretty cool to see RTL support in Tailwind 3.0, even if experimental, but looking at the example given ( Re naming clashes – as far as I understand it’s much more common for people to create layouts that can be mirrored horizontally (RTL <-> LTR) with "inline" properties, than to create layouts that can be mirrored vertically or turned 90 degrees. So the "block" vs "bottom" clash doesn’t seem that concerning to me – since |
Beta Was this translation helpful? Give feedback.
-
I expect we'll revisit this one again this year for sure, last time I looked into it the browser support for certain things like Hardest part is for sure the naming conventions, so keep sharing your suggestions, it'll be helpful to refer to when I do decide to jump on this feature again. |
Beta Was this translation helpful? Give feedback.
-
Thought I’d share another approach as a plugin in case it helps others: tailwindcss-vanilla-rtl. This overrides all Tailwind core left/right utilities, so they output logical properties and values instead. The utility names are unchanged. We put this together for a large project, choosing this approach to sidestep the naming conventions dilemma, and so people don’t have to constantly remember whether they are using Tailwind on a project that needs RTL support or not. |
Beta Was this translation helpful? Give feedback.
-
Just wanted to follow up again here — I really like the overall idea @thibaudcolas proposed, where we just worry about logical properties in the inline direction and ignore the block direction, since the block direction is the only place where there are naming collisions to be concerned about. This lets us make some forward progress and solve the block problem down the road if there is actually demand for it. Going to hack on this for v3.3, probably have something people can play with in January some time 👍 |
Beta Was this translation helpful? Give feedback.
-
Opened a PR with support for logical properties in the inline direction: Thanks for all the input here everyone! |
Beta Was this translation helpful? Give feedback.
-
Guess this discussion can be closed as v3.3 is out with logical properties support 🎉 |
Beta Was this translation helpful? Give feedback.
-
v3.3 is great! Some utilities missing: There might be more. |
Beta Was this translation helpful? Give feedback.
-
👋 browser support now feels good enough for flow-relative |
Beta Was this translation helpful? Give feedback.
-
I'm building my first project which required ltr and rtl. The in-house support in 3.4.3 is great in most areas but space-x-# still uses left / right rather than inline-start / end. Is there an easy way to change this without having to update all of my classes? |
Beta Was this translation helpful? Give feedback.
-
I suggest using Therefore:
As
However this could create confusion when |
Beta Was this translation helpful? Give feedback.
-
[Feature Proposal]
First of all - Thank you! Love Tailwindcss! 😍
For margin, padding, borders etc:
I think it would be great to add utilities for
margin-inline-start
&margin-inline-end
[same for padding & borders], which will help greatly with layouts of all directions.This approach will make building bi-directional layouts much easier, let us write less code: write only one class that will handle both directions.
Or at least can somebody point out how to add it myself, with
tailwind.config.js
.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions