Skip to content

Support subtree direction for the rtl: variant (currently resolved globally) #573

@istarkov

Description

@istarkov

Uniwind 1.3.0 Pro: subtree-scoped rtl: support

When in Arabic interfaces, it's not rare when you have an English UI but the data you are receiving on a request is in Arabic and vice versa.

We always need to support subtrees with a different direction.
That works perfectly in Tailwind on the web. React Native also supports this using a direction CSS style:

<View style={{ direction: "rtl" }}>

But seems like Uniwind is using a global value for the rtl: variant.

That’s really needed for Arabic interfaces instead of using:

cn(isRtl ? "" : "")

Repro

// App direction is LTR (I18nManager.isRTL === false)
<View style={{ direction: "rtl" }}>
  {/* Yoga: flips correctly — S/E markers swap, ps-* moves to the right edge */}
  <View className="flex-row ps-10"></View>

  {/* Uniwind: stays blue — rtl: doesn't see the subtree direction */}
  <View className="bg-blue-500 rtl:bg-red-500" />
</View>

Seems like this is doable in uniwind, having group etc support.
And I think it's great pro feature for the library.

PS:

Tailwind v4 web:

rtl: variant compiles to &:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *)

That’s an ancestor selector — the nearest dir attribute wins, so a dir="rtl" subtree flips its rtl: classes while the rest of the page stays LTR. Subtree-scoped by design.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions