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

space-x-* does not work in RTL direction #2017

Closed
chalist opened this issue Jul 13, 2020 · 13 comments
Closed

space-x-* does not work in RTL direction #2017

chalist opened this issue Jul 13, 2020 · 13 comments

Comments

@chalist
Copy link

chalist commented Jul 13, 2020

image

@chalist
Copy link
Author

chalist commented Jul 13, 2020

I fix this by doing this:

[dir="rtl"] {
    .space-x-4 > :not(template) ~ :not(template) {
        --space-x-reverse: 0 !important;
        margin-left: calc(1rem * var(--space-x-reverse)) !important;
        margin-right: calc(1rem * calc(1 - var(--space-x-reverse))) !important;
    }
}

But I would like to know, there is a way to make space without depends on direction?

@chalist
Copy link
Author

chalist commented Jul 13, 2020

#2020

@royvanv
Copy link

royvanv commented Jul 17, 2020

@hsul4n
Copy link

hsul4n commented Jul 18, 2020

Just use tailwindcss-dir and add space variant to tailwind.config.js

variants: {
  space: ['responsive', 'direction'],
},

@mohamed-ibrahem
Copy link

mohamed-ibrahem commented Jul 18, 2020

@hsul4n Not working! still, the margin in the last item and none in the first one 😟

@chalist
Copy link
Author

chalist commented Jul 18, 2020

@hsul4n Not working! still, the margin in the last item and none in the first one

I fixed this problem by this code:

[dir="rtl"] {
    .space-x-4 > :not(template) ~ :not(template) {
        --space-x-reverse: 0 !important;
        margin-left: calc(1rem * var(--space-x-reverse)) !important;
        margin-right: calc(1rem * calc(1 - var(--space-x-reverse))) !important;
    }
}

@mohamed-ibrahem
Copy link

@chalist good trick.
But I think the following way is much easier

variants: {
  space: ['responsive', 'direction'],
},

then you can do something like
space-x-6 rtl:space-x-reverse ✌✌

Saves much time, isn't it?

@chalist
Copy link
Author

chalist commented Jul 18, 2020

yes sure. But you wrote not working. This is because I write that comment :D

@mohamed-ibrahem
Copy link

yes sure. But you wrote not working. This is because I write that comment :D

Thank you 👍

@chalist chalist closed this as completed Jul 18, 2020
@hsul4n
Copy link

hsul4n commented Jul 19, 2020

Sorry @mohamed-ibrahem, I always add style utilities to variants property but looks like this doesn't work with space utility 😅, so I would suggest using reverse with RTL direction.

Here's example

<div class="flex space-x-4 rtl:space-x-reverse">
  <div>1</div>
  <div>2</div>
  <div>3</div>
</div>

@Nefcanto
Copy link

@hsul4n your solution was the best one. Worked for me. Thank you.

@ghost
Copy link

ghost commented Dec 30, 2021

<div class="flex space-x-4 rtl:space-x-reverse">

it work for me thank you,

@alisamie97
Copy link

For 2021 and tailwind v2 i used only this and works
class='space-x-6 space-x-reverse'

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

6 participants