Skip to main content
Available in Uniwind 1.9.0+ (Free) and 1.4.0+ (Pro)

Overview

LayoutDirection lets you force right-to-left or left-to-right layout for a specific subtree without changing the global device RTL state. This is useful for previews, mixed-direction layouts (for example, an RTL chat bubble inside an LTR app), and testing RTL designs side by side. The nearest LayoutDirection wins, so nested scopes work naturally.
LayoutDirection is a runtime direction boundary. The rtl: and ltr: variants, hooks, and withUniwind wrapped components inside the boundary resolve against the scoped direction instead of the global RTL state.

Usage

Basic Example

Common Patterns

Side-by-Side Direction Previews

Nested Scopes

Omit the rtl prop to inherit the direction from the nearest parent LayoutDirection. Outside of any scope, it falls back to the global RTL state.

Hooks and withUniwind in a Layout Direction Scope

Hooks and HOCs resolve against the closest LayoutDirection boundary:
  • useResolveClassNames() resolves rtl:/ltr: variants using the scoped direction
  • withUniwind() mappings use values resolved from the scoped direction

API Reference

Component Signature

Props

boolean
true forces right-to-left, false forces left-to-right. When omitted, the subtree inherits the direction from the nearest parent LayoutDirection, or the global RTL state if there is none.
React.ReactNode
required
React children rendered inside the layout direction boundary.

Behavior Notes

  • LayoutDirection affects only its descendants
  • It does not change the global RTL state (I18nManager on native, the document dir on web)
  • Nested scopes override parent scopes for their own subtree
  • The wrapper renders with display: contents, so it does not affect your layout
  • Prefer LayoutDirection over inline style={{ direction: 'rtl' }} - only the component scopes the rtl:/ltr: variants

Class Names

All supported variants, including rtl: and ltr:

Scoped Themes

Apply a different theme to a subtree

useResolveClassNames

Resolve class names into style objects at runtime

withUniwind

Add className support to third-party components