import { Stack, Text, useRTL } from "@vortexlabs/vortex-native";
const Example = () => {
const [rtl] = useRTL();
return (
<Stack gap={2}>
<Text>{rtl ? "Right to left" : "Left to right"}</Text>
<Stack direction="row" gap={2}>
<Text>1. Start</Text>
<Text>2. Middle</Text>
<Text>3. End</Text>
</Stack>
</Stack>
);
};Features
- Reads the app's layout direction.
- Changes the direction through React Native
I18nManager. - Supports mirrored rows and
startandendalignment in right-to-left layouts.
Changing Direction
setRTL allows and forces the direction with I18nManager. React Native applies it after the app reloads, so rtl doesn't change in the current session. Reload the app after calling it, for example with expo-updates reloadAsync.
import { reloadAsync } from "expo-updates";
const [rtl, setRTL] = useRTL();
const switchToRTL = async () => {
setRTL(true);
await reloadAsync();
};