Back to results for “Internationalization (i18n) in React”
React › Internationalization (i18n) in React

How do you handle right to left languages, like Arabic, in a React app?

Intermediate

Answer

You set the direction attribute on your page, usually to rtl for right to left languages, which flips the layout so text and elements read from right to left instead of left to right. Your CSS may also need adjustments so spacing and icons that assume a left to right layout still look correct when flipped.
function App({ language }) {
  const direction = language === 'ar' ? 'rtl' : 'ltr';
  return (
    <div dir={direction}>
      <MainContent />
    </div>
  );
}
Real-world example An app expanding into Middle Eastern markets automatically flips its entire layout to read right to left for Arabic speaking users, while keeping the normal left to right layout for everyone else.

Common follow-ups: What specific CSS properties commonly need special handling for right to left layouts?;How do you test that a right to left layout looks correct without knowing Arabic yourself?