There is a couple of ways to do the text RTL in react native and it depends on what you prefer and what is your use case:-
Option 1:
useing alignSelf: 'flex-start'
style property, for example
<Text style={{alignSelf: "flex-start"}}>your text here</Text>
This approach is a text language sensitive and will make the text align and language writing direction depend on the text language itself, i.e. if the text was in English then the text will be LTR as a direction and the whole text will be aligned at the left but if the text is in Arabic it will be RTL as a direction and the whole text will be aligned at the right automatically.
Option 2:
As the React Native Text docs you can use these style properties writingDirection: "rtl"
for IOS and textAlign: "justify"
for Android, for example:
import { I18nManager, Text } from "react-native";
<Text style={{
writingDirection: I18nManager.isRTL ? "rtl" : "ltr", //OR "auto"
textAlign: "justify"
}}>
your text here
</Text>
In this approach using justify
for Android it will not be text language sensitive, instead, it will be the app I18nManager.isRTL
sensitive and it will align the text depending on it regardless if the text is in Arabic or English just will use the app direction state. it will be only language writing direction sensitive unlike option 1, but for IOS you should write a condition that provides the dynamic value as the example above. so this approach is preferable if you don't want to show a mess of text especially if you have both languages at the same view, i.e. if you have two different descriptions one in English and one in Arabic at the same view but you want to make both texts at the same level of text aligning for the design practices.