Working with RTL languages
Compose Multiplatform provides support for Right-to-Left (RTL) languages such as Arabic, Hebrew, and Persian. The framework automatically handles most RTL requirements and adjusts layouts, alignment, and text input behavior according to the system's locale settings when RTL languages are used.
Layout mirroring
When the system locale is configured for an RTL language, Compose Multiplatform automatically mirrors most UI components. Adjustments include changes to paddings, alignments, and component positions:
Paddings, margins, and alignments
Default paddings and alignments are reversed. For example, inModifier.padding(start: Dp, top: Dp, end: Dp, bottom: Dp)
, the LTRstart
padding corresponds to the left side, and theend
padding corresponds to the right side; whereas in RTL languages,start
corresponds to the right side, andend
corresponds to the left side.Component alignment
For UI elements like text, navigation items, and icons, the defaultStart
alignment becomesEnd
in RTL mode.Horizontally scrollable lists
Horizontal lists reverse their item alignment and scroll direction.Button positioning
Common UI patterns, such as the position of Cancel and Confirm buttons, adjust to RTL expectations.
Forcing layout direction
You may need to keep the original orientation of some UI elements, such as logos or icons, regardless of layout direction. You can explicitly set the layout direction for an entire app or individual components, overriding the system's default locale-based layout behavior.
To exclude an element from automatic mirroring and enforce a specific orientation, you can use LayoutDirection.Rtl
or LayoutDirection.Ltr
. To specify a layout direction within a scope, use the CompositionLocalProvider()
, which ensures that the layout direction applies to all child components in the composition:
Handling text input in RTL layouts
Compose Multiplatform provides support for various scenarios of text input in RTL layouts, including mixed-direction content, special characters, numbers, and emojis.
When you design an application that supports an RTL layout, consider the following aspects. Testing them can help you identify potential localization issues.
Cursor behavior
The cursor should behave intuitively within RTL layouts, aligning with the logical direction of characters. For example:
When typing in Arabic, the cursor moves right-to-left, but inserting LTR content follows left-to-right behavior.
Operations like text selection, deletion, and insertion respect the text's natural directional flow.
BiDi text
Compose Multiplatform uses the Unicode Bidirectional Algorithm to manage and render bidirectional (BiDi) text, aligning punctuation and numbers.
The text should be displayed in the expected visual order: punctuation and numbers are aligned correctly, the Arabic script flows from right to left, and English flows from left to right.
The following test sample includes text with Latin and Arabic letters, and their bidirectional combination:

Compose Multiplatform also ensures proper alignment and spacing in complex BiDi cases, including multi-line wrapping and nesting of BiDi content.
Numbers and emojis
Numbers should be displayed consistently based on the direction of the surrounding text. Eastern Arabic numerals align naturally in RTL text, and Western Arabic numerals follow typical LTR behavior.
Emojis should adapt to both RTL and LTR contexts, maintaining proper alignment and spacing within the text.
The following test sample includes emojis, Eastern and Western Arabic numerals, and bidirectional text:

Accessibility in RTL layouts
Compose Multiplatform supports accessibility features for RTL layouts, including proper text direction and order for screen readers and handling of gestures.
Screen readers
Screen readers automatically adapt to RTL layouts, keeping the logical reading order for users:
RTL text is read from right to left, and mixed-direction text follows standard BiDi rules.
Punctuation and numbers are announced in the correct sequence.
In complex layouts, it's necessary to define traversal semantics to ensure the correct reading order for screen readers.
Focus-based navigation
Focus navigation in RTL layouts follows the layout's mirrored structure:
Focus moves from right to left and top to bottom, following the natural flow of RTL content.
Gestures like swipes or taps are automatically adjusted to the mirrored layout.
You can also define traversal semantics to ensure correct navigation between different traversal groups with the swipe-up or swipe-down accessibility gestures.
For details on how to define traversal semantics and set traversal indexes, refer to the Accessibility section.
Known issues
We keep improving support for RTL languages and plan to address the following known issues: